
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>MySQL · My Study Note</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="yanglonglong">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Redis.html" />
    
    
    <link rel="prev" href="MVCC.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.yangllong.top/" target="_blank" class="custom-link">My Blog</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Linux相关/">
            
                <a href="../Linux相关/">
            
                    
                    Linux相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Linux相关/make工具的使用.html">
            
                <a href="../Linux相关/make工具的使用.html">
            
                    
                    Make工具的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../springboot/">
            
                <a href="../springboot/">
            
                    
                    Springboot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../springboot/springboot一些遇到的问题.html">
            
                <a href="../springboot/springboot一些遇到的问题.html">
            
                    
                    Springboot一些遇到的问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/vue+ssm跨域问题.html">
            
                <a href="../vue/vue+ssm跨域问题.html">
            
                    
                    Vue+Ssm跨域问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/vue-cli3.html">
            
                <a href="../vue/vue-cli3.html">
            
                    
                    Vue Cli3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../vue/安装vue.html">
            
                <a href="../vue/安装vue.html">
            
                    
                    安装Vue
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../其他/">
            
                <a href="../其他/">
            
                    
                    其他
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../其他/分布式系统.html">
            
                <a href="../其他/分布式系统.html">
            
                    
                    分布式系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../其他/图解http.html">
            
                <a href="../其他/图解http.html">
            
                    
                    图解Http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../其他/消息队列.html">
            
                <a href="../其他/消息队列.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../其他/爬虫.html">
            
                <a href="../其他/爬虫.html">
            
                    
                    爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../刷题/">
            
                <a href="../刷题/">
            
                    
                    刷题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../刷题/NOJ.html">
            
                <a href="../刷题/NOJ.html">
            
                    
                    NOJ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../刷题/leetcode/">
            
                <a href="../刷题/leetcode/">
            
                    
                    Leetcode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../刷题/leetcode/107简单题.html">
            
                <a href="../刷题/leetcode/107简单题.html">
            
                    
                    107简单题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.3.1" data-path="../刷题/leetcode/2两数相加.html">
            
                <a href="../刷题/leetcode/2两数相加.html">
            
                    
                    2两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.2" data-path="../刷题/leetcode/3无重复子串的最大长度.html">
            
                <a href="../刷题/leetcode/3无重复子串的最大长度.html">
            
                    
                    3无重复子串的最大长度
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../刷题/扇贝杯csdn.html">
            
                <a href="../刷题/扇贝杯csdn.html">
            
                    
                    扇贝杯Csdn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../刷题/排序算法.html">
            
                <a href="../刷题/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../刷题/蓝桥杯.html">
            
                <a href="../刷题/蓝桥杯.html">
            
                    
                    蓝桥杯
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../刷题/蓝桥杯热身赛.html">
            
                <a href="../刷题/蓝桥杯热身赛.html">
            
                    
                    蓝桥杯热身赛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../刷题/计算机等级考试(C语言">
            
                <span>
            
                    
                    计算机等级考试(C语言)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../博客/">
            
                <a href="../博客/">
            
                    
                    博客
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../博客/next主题配置.html">
            
                <a href="../博客/next主题配置.html">
            
                    
                    Next主题配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../博客/一些问题的记录.html">
            
                <a href="../博客/一些问题的记录.html">
            
                    
                    一些问题的记录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../学习java/">
            
                <a href="../学习java/">
            
                    
                    学习Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../学习java/AQS.html">
            
                <a href="../学习java/AQS.html">
            
                    
                    AQS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../学习java/HashMap的简单实现.html">
            
                <a href="../学习java/HashMap的简单实现.html">
            
                    
                    HashMap的简单实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../学习java/JavaByteCode.html">
            
                <a href="../学习java/JavaByteCode.html">
            
                    
                    JavaByteCode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../学习java/Java基础.html">
            
                <a href="../学习java/Java基础.html">
            
                    
                    Java基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../学习java/Java多线程.html">
            
                <a href="../学习java/Java多线程.html">
            
                    
                    Java多线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../学习java/Java多线程并发.html">
            
                <a href="../学习java/Java多线程并发.html">
            
                    
                    Java多线程并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../学习java/Java爬虫.html">
            
                <a href="../学习java/Java爬虫.html">
            
                    
                    Java爬虫
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../学习java/Java集合.html">
            
                <a href="../学习java/Java集合.html">
            
                    
                    Java集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../学习java/java常用类.html">
            
                <a href="../学习java/java常用类.html">
            
                    
                    Java常用类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../学习java/jvm.html">
            
                <a href="../学习java/jvm.html">
            
                    
                    Jvm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.11" data-path="../学习java/noifelse.html">
            
                <a href="../学习java/noifelse.html">
            
                    
                    Noifelse
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.12" data-path="../学习java/socket.html">
            
                <a href="../学习java/socket.html">
            
                    
                    Socket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.13" data-path="../学习java/一些Java方法.html">
            
                <a href="../学习java/一些Java方法.html">
            
                    
                    一些Java方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.14" data-path="../学习java/一些其他人写的博客.html">
            
                <a href="../学习java/一些其他人写的博客.html">
            
                    
                    一些其他人写的博客
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.15" data-path="../学习java/硬核空间.html">
            
                <a href="../学习java/硬核空间.html">
            
                    
                    硬核空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.16" data-path="../学习java/遇到的问题.html">
            
                <a href="../学习java/遇到的问题.html">
            
                    
                    遇到的问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.17" data-path="../学习java/阻塞队列.html">
            
                <a href="../学习java/阻塞队列.html">
            
                    
                    阻塞队列
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../安卓开发/">
            
                <a href="../安卓开发/">
            
                    
                    安卓开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../安卓开发/First App.html">
            
                <a href="../安卓开发/First App.html">
            
                    
                    First App
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../安卓开发/problems.html">
            
                <a href="../安卓开发/problems.html">
            
                    
                    Problems
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../工具/">
            
                <a href="../工具/">
            
                    
                    工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../工具/IDEA.html">
            
                <a href="../工具/IDEA.html">
            
                    
                    IDEA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../工具/docker.html">
            
                <a href="../工具/docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../工具/github.html">
            
                <a href="../工具/github.html">
            
                    
                    Github
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="./">
            
                <a href="./">
            
                    
                    数据库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="MVCC.html">
            
                <a href="MVCC.html">
            
                    
                    MVCC
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.11.2" data-path="MySQL.html">
            
                <a href="MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="Redis.html">
            
                <a href="Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../数据结构知识/">
            
                <a href="../数据结构知识/">
            
                    
                    数据结构知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../数据结构知识/大话数据结构笔记1.html">
            
                <a href="../数据结构知识/大话数据结构笔记1.html">
            
                    
                    大话数据结构笔记1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../数据结构知识/大话数据结构笔记2.html">
            
                <a href="../数据结构知识/大话数据结构笔记2.html">
            
                    
                    大话数据结构笔记2
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../面试笔试/">
            
                <a href="../面试笔试/">
            
                    
                    面试笔试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../面试笔试/字节跳动5月11日笔试.html">
            
                <a href="../面试笔试/字节跳动5月11日笔试.html">
            
                    
                    字节跳动5月11日笔试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../面试笔试/阿里3月23日笔试.html">
            
                <a href="../面试笔试/阿里3月23日笔试.html">
            
                    
                    阿里3月23日笔试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../面试笔试/面试突击.html">
            
                <a href="../面试笔试/面试突击.html">
            
                    
                    面试突击
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >MySQL</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="mysql">MySQL</h2>
<p>&#x884C;&#xFF1A;&#x8868;&#x4E2D;&#x7684;&#x4E00;&#x4E2A;&#x8BB0;&#x5F55;</p>
<p>&#x4E3B;&#x952E;&#xFF08;primary key&#xFF09;&#xFF1A;&#x4E00;&#x5217;&#xFF08;&#x6216;&#x4E00;&#x7EC4;&#x5217;&#xFF09;&#xFF0C;&#x5176;&#x503C;&#x80FD;&#x552F;&#x4E00;&#x533A;&#x5206;&#x8868;&#x4E2D;&#x6BCF;&#x4E2A;&#x884C;</p>
<h3 id="&#x4F7F;&#x7528;mysql">&#x4F7F;&#x7528;MySQL</h3>
<p>&#x5C55;&#x793A;&#x6240;&#x6709;&#x6570;&#x636E;&#x5E93;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-keyword">databases</span>;
</code></pre>
<p>&#x9009;&#x62E9;&#x6570;&#x636E;&#x5E93;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">use</span> crashcourse;
</code></pre>
<p>&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x5185;&#x7684;&#x8868;&#x7684;&#x5217;&#x8868;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-keyword">tables</span>;
</code></pre>
<p>&#x663E;&#x793A;&#x8868;&#x5217;&#xFF0C;&#x9700;&#x8981;&#x7ED9;&#x51FA;&#x8868;&#x540D;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-keyword">columns</span> <span class="hljs-keyword">from</span> customers;
<span class="hljs-comment">-- &#x4E0B;&#x9762;&#x8BED;&#x53E5;&#x7B49;&#x4EF7;</span>
<span class="hljs-keyword">describe</span> customers;
</code></pre>
<p>&#x5176;&#x4ED6;show&#x8BED;&#x53E5;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-keyword">status</span>;    <span class="hljs-comment">-- &#x663E;&#x793A;&#x5E7F;&#x6CDB;&#x7684;&#x670D;&#x52A1;&#x5668;&#x72B6;&#x6001;&#x4FE1;&#x606F;</span>
<span class="hljs-keyword">show</span> <span class="hljs-keyword">create</span> <span class="hljs-keyword">database</span>;    <span class="hljs-comment">-- &#x663E;&#x793A;&#x521B;&#x5EFA;&#x7279;&#x5B9A;&#x6570;&#x636E;&#x5E93;</span>
<span class="hljs-keyword">show</span> <span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span>;    <span class="hljs-comment">-- &#x663E;&#x793A;&#x521B;&#x5EFA;&#x7279;&#x5B9A;&#x8868;</span>
<span class="hljs-keyword">show</span> <span class="hljs-keyword">grants</span>;    <span class="hljs-comment">-- &#x663E;&#x793A;&#x6388;&#x4E88;&#x7528;&#x6237;&#x7684;&#x5B89;&#x5168;&#x6743;&#x9650;</span>
<span class="hljs-keyword">show</span> <span class="hljs-keyword">errors</span>;    <span class="hljs-comment">-- &#x663E;&#x793A;&#x670D;&#x52A1;&#x5668;&#x9519;&#x8BEF;</span>
<span class="hljs-keyword">show</span> <span class="hljs-keyword">warnings</span>;    <span class="hljs-comment">--&#x663E;&#x793A;&#x670D;&#x52A1;&#x5668;&#x8B66;&#x544A;</span>
</code></pre>
<p>&#x8FDB;&#x4E00;&#x6B65;&#x4E86;&#x89E3;show</p>
<pre><code class="lang-sql"><span class="hljs-keyword">help</span> <span class="hljs-keyword">show</span>;
</code></pre>
<h3 id="&#x68C0;&#x7D22;&#x6570;&#x636E;">&#x68C0;&#x7D22;&#x6570;&#x636E;</h3>
<h4 id="select&#x8BED;&#x53E5;">select&#x8BED;&#x53E5;</h4>
<p>&#x68C0;&#x7D22;&#x5355;&#x4E2A;&#x5217;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products;
</code></pre>
<p>&#x68C0;&#x7D22;&#x591A;&#x4E2A;&#x5217;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_name, prod_name <span class="hljs-keyword">from</span> products;
</code></pre>
<p>&#x68C0;&#x7D22;&#x6240;&#x6709;&#x5217;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> * <span class="hljs-keyword">from</span> products;
</code></pre>
<p>&#x68C0;&#x7D22;&#x4E0D;&#x540C;&#x7684;&#x884C;&#xFF08;&#x6570;&#x636E;&#x4E0D;&#x91CD;&#x590D;&#xFF09;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> <span class="hljs-keyword">distinct</span> vend_id <span class="hljs-keyword">from</span> products;    <span class="hljs-comment">-- distinct&#x653E;&#x5728;&#x5217;&#x540D;&#x524D;&#x9762;</span>
</code></pre>
<p>&#x9650;&#x5236;&#x7ED3;&#x679C; </p>
<h5 id="limit&#x5B50;&#x53E5;">LIMIT&#x5B50;&#x53E5;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">limit</span> <span class="hljs-number">5</span>;    <span class="hljs-comment">-- &#x53EA;&#x8FD4;&#x56DE;&#x524D;5&#x884C;&#x6570;&#x636E;&#xFF0C;&#x4E0D;&#x591F;5&#x884C;&#x5219;&#x8FD4;&#x56DE;&#x6240;&#x6709;&#x6570;&#x636E;</span>
<span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">limit</span> <span class="hljs-number">5</span>,<span class="hljs-number">5</span>;    <span class="hljs-comment">-- &#x8FD4;&#x56DE;&#x4ECE;&#x884C;5&#x5F00;&#x59CB;&#x7684;5&#x884C;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x6570;&#x4E3A;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x6570;&#x4E3A;&#x884C;&#x6570;</span>
</code></pre>
<p>==&#x7B2C;&#x4E00;&#x884C;&#x4E3A;&#x884C;0==</p>
<p>&#x4F7F;&#x7528;&#x5B8C;&#x5168;&#x9650;&#x5B9A;&#x7684;&#x8868;&#x540D;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> products.prod_name <span class="hljs-keyword">from</span> products;
<span class="hljs-keyword">select</span> products.prod_name <span class="hljs-keyword">from</span> crashcourse.products;
</code></pre>
<h3 id="&#x68C0;&#x7D22;&#x6392;&#x5E8F;&#x6570;&#x636E;">&#x68C0;&#x7D22;&#x6392;&#x5E8F;&#x6570;&#x636E;</h3>
<h4 id="&#x6392;&#x5E8F;&#x6570;&#x636E;">&#x6392;&#x5E8F;&#x6570;&#x636E;</h4>
<h5 id="order-by&#x5B50;&#x53E5;">ORDER BY&#x5B50;&#x53E5;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<p>&#x6309;&#x591A;&#x4E2A;&#x5217;&#x6392;&#x5E8F;</p>
<blockquote>
<p>&#x9996;&#x5148;&#x6309;prod_price&#x6392;&#x5E8F;&#xFF0C;prod_price&#x76F8;&#x540C;&#x624D;&#x6309;prod_name</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_price, prod_name;
</code></pre>
<p>&#x6307;&#x5B9A;&#x6392;&#x5E8F;&#x65B9;&#x5411;</p>
<blockquote>
<p>&#x9ED8;&#x8BA4;&#x5347;&#x5E8F;(ASC)&#xFF0C;&#x4F7F;&#x7528;DESC&#x5173;&#x952E;&#x5B57;&#x964D;&#x5E8F;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_price <span class="hljs-keyword">DESC</span>;
</code></pre>
<p>&#x5148;&#x6309;prod_price&#x964D;&#x5E8F;&#xFF0C;&#x518D;&#x6309;prod_name&#x5347;&#x5E8F;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_price <span class="hljs-keyword">DESC</span>, prod_name;
</code></pre>
<h3 id="&#x8FC7;&#x6EE4;&#x6570;&#x636E;">&#x8FC7;&#x6EE4;&#x6570;&#x636E;</h3>
<h4 id="&#x4F7F;&#x7528;where&#x5B50;&#x53E5;">&#x4F7F;&#x7528;WHERE&#x5B50;&#x53E5;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_price = <span class="hljs-number">2.50</span>;
</code></pre>
<h4 id="where&#x5B50;&#x53E5;&#x64CD;&#x4F5C;&#x7B26;">where&#x5B50;&#x53E5;&#x64CD;&#x4F5C;&#x7B26;</h4>
<table>
<thead>
<tr>
<th>&#x64CD;&#x4F5C;&#x7B26;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>=</td>
<td>&#x7B49;&#x4E8E;</td>
</tr>
<tr>
<td>&lt;&gt;</td>
<td>&#x4E0D;&#x7B49;&#x4E8E;</td>
</tr>
<tr>
<td>!=</td>
<td>&#x4E0D;&#x7B49;&#x4E8E;</td>
</tr>
<tr>
<td>&lt;</td>
<td>&#x5C0F;&#x4E8E;</td>
</tr>
<tr>
<td>&lt;=</td>
<td>&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E;</td>
</tr>
<tr>
<td>&gt;</td>
<td>&#x5927;&#x4E8E;</td>
</tr>
<tr>
<td>&gt;=</td>
<td>&#x5927;&#x4E8E;&#x7B49;&#x4E8E;</td>
</tr>
<tr>
<td>BETWEEN</td>
<td>&#x5728;&#x6307;&#x5B9A;&#x4E24;&#x4E2A;&#x503C;&#x4E4B;&#x95F4;</td>
</tr>
</tbody>
</table>
<h4 id="&#x8303;&#x56F4;&#x503C;&#x68C0;&#x67E5;">&#x8303;&#x56F4;&#x503C;&#x68C0;&#x67E5;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_price <span class="hljs-keyword">between</span> <span class="hljs-number">5</span> <span class="hljs-keyword">and</span> <span class="hljs-number">10</span>;
</code></pre>
<h4 id="&#x7A7A;&#x503C;&#x68C0;&#x67E5;">&#x7A7A;&#x503C;&#x68C0;&#x67E5;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_price <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span>;
</code></pre>
<h3 id="&#x6570;&#x636E;&#x8FC7;&#x6EE4;">&#x6570;&#x636E;&#x8FC7;&#x6EE4;</h3>
<h4 id="&#x7EC4;&#x5408;where&#x5B50;&#x53E5;">&#x7EC4;&#x5408;where&#x5B50;&#x53E5;</h4>
<blockquote>
<p>&#x5141;&#x8BB8;&#x7ED9;&#x51FA;&#x591A;&#x4E2A;where&#x5B50;&#x53E5;&#xFF0C;&#x5B50;&#x53E5;&#x4E4B;&#x95F4;&#x7528;AND&#x6216;OR&#x8054;&#x7ED3;</p>
</blockquote>
<h5 id="and&#x64CD;&#x4F5C;&#x7B26;">AND&#x64CD;&#x4F5C;&#x7B26;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> vend_id = <span class="hljs-number">1003</span> <span class="hljs-keyword">AND</span> prod_price &lt;= <span class="hljs-number">10</span>;
</code></pre>
<h5 id="or&#x64CD;&#x4F5C;&#x7B26;">OR&#x64CD;&#x4F5C;&#x7B26;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> vend_id = <span class="hljs-number">1002</span> <span class="hljs-keyword">OR</span> vend_id = <span class="hljs-number">1003</span>;
</code></pre>
<h5 id="&#x8BA1;&#x7B97;&#x6B21;&#x5E8F;">&#x8BA1;&#x7B97;&#x6B21;&#x5E8F;</h5>
<p>&#x5BF9;&#x4E8E;&#x4E0B;&#x9762;&#x7684;&#x8BED;&#x53E5;&#xFF0C;&#x4F18;&#x5148;&#x5904;&#x7406;AND&#x64CD;&#x4F5C;&#x7B26;&#xFF08;AND&#x64CD;&#x4F5C;&#x7B26;&#x5728;&#x8BA1;&#x7B97;&#x6B21;&#x5E8F;&#x4E2D;&#x4F18;&#x5148;&#x7EA7;&#x66F4;&#x9AD8;&#xFF09;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> vend_id = <span class="hljs-number">1002</span> <span class="hljs-keyword">OR</span> vend_id = <span class="hljs-number">1003</span> <span class="hljs-keyword">AND</span> prod_price &gt;= <span class="hljs-number">10</span>;
</code></pre>
<p>&#x5982;&#x679C;&#x9700;&#x8981;&#x5148;&#x8BA1;&#x7B97;OR&#x8054;&#x7ED3;&#x7684;&#x8BED;&#x53E5;&#xFF0C;&#x9700;&#x8981;&#x52A0;&#x62EC;&#x53F7;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> (vend_id = <span class="hljs-number">1002</span> <span class="hljs-keyword">OR</span> vend_id = <span class="hljs-number">1003</span>) <span class="hljs-keyword">AND</span> prod_price &gt;= <span class="hljs-number">10</span>;
</code></pre>
<h5 id="in&#x64CD;&#x4F5C;&#x7B26;">IN&#x64CD;&#x4F5C;&#x7B26;</h5>
<blockquote>
<p>in&#x7528;&#x6765;&#x6307;&#x5B9A;&#x6761;&#x4EF6;&#x8303;&#x56F4;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> vend_id <span class="hljs-keyword">in</span>(<span class="hljs-number">1002</span>,<span class="hljs-number">1003</span>) <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<h5 id="not&#x64CD;&#x4F5C;&#x7B26;">NOT&#x64CD;&#x4F5C;&#x7B26;</h5>
<blockquote>
<p>&#x5426;&#x5B9A;&#x540E;&#x9762;&#x7684;&#x6761;&#x4EF6;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_price, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> vend_id <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span>(<span class="hljs-number">1002</span>,<span class="hljs-number">1003</span>) <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<h3 id="&#x7528;&#x901A;&#x914D;&#x7B26;&#x8FC7;&#x6EE4;">&#x7528;&#x901A;&#x914D;&#x7B26;&#x8FC7;&#x6EE4;</h3>
<h4 id="like&#x64CD;&#x4F5C;&#x7B26;">LIKE&#x64CD;&#x4F5C;&#x7B26;</h4>
<h5 id="&#x901A;&#x914D;&#x7B26;">%&#x901A;&#x914D;&#x7B26;</h5>
<blockquote>
<p>&#x8868;&#x793A;&#x4EFB;&#x4F55;&#x5B57;&#x7B26;&#x51FA;&#x73B0;&#x4EFB;&#x4F55;&#x6B21;&#x6570;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name <span class="hljs-keyword">like</span> <span class="hljs-string">&apos;jet%&apos;</span>;
</code></pre>
<h5 id="&#x901A;&#x914D;&#x7B26;">_&#x901A;&#x914D;&#x7B26;</h5>
<blockquote>
<p>&#x5339;&#x914D;&#x5355;&#x4E2A;&#x4EFB;&#x610F;&#x5B57;&#x7B26;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id, prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name <span class="hljs-keyword">like</span> <span class="hljs-string">&apos;_ ton anvil&apos;</span>;
</code></pre>
<h4 id="&#x4F7F;&#x7528;&#x901A;&#x914D;&#x7B26;&#x6280;&#x5DE7;">&#x4F7F;&#x7528;&#x901A;&#x914D;&#x7B26;&#x6280;&#x5DE7;</h4>
<ul>
<li>&#x4E0D;&#x8981;&#x8FC7;&#x5EA6;&#x4F7F;&#x7528;&#x901A;&#x914D;&#x7B26;&#x3002;&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x80FD;&#x8FBE;&#x5230;&#x76F8;&#x540C;&#x76EE;&#x7684;&#x7684;&#x64CD;&#x4F5C;&#x7B26;&#x3002;</li>
<li>&#x9664;&#x975E;&#x7EDD;&#x5BF9;&#x6709;&#x5FC5;&#x8981;&#xFF0C;&#x5426;&#x5219;&#x4E0D;&#x8981;&#x628A;&#x901A;&#x914D;&#x7B26;&#x653E;&#x5728;&#x641C;&#x7D22;&#x6A21;&#x5F0F;&#x7684;&#x5F00;&#x59CB;&#x5904;&#x3002;&#x8FD9;&#x6837;&#x641C;&#x7D22;&#x8D77;&#x6765;&#x662F;&#x6700;&#x6162;&#x7684;</li>
<li>&#x4ED4;&#x7EC6;&#x6CE8;&#x610F;&#x901A;&#x914D;&#x7B26;&#x7684;&#x4F4D;&#x7F6E;</li>
</ul>
<h3 id="&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x8FDB;&#x884C;&#x641C;&#x7D22;">&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x8FDB;&#x884C;&#x641C;&#x7D22;</h3>
<h4 id="&#x57FA;&#x672C;&#x5B57;&#x7B26;&#x5339;&#x914D;">&#x57FA;&#x672C;&#x5B57;&#x7B26;&#x5339;&#x914D;</h4>
<blockquote>
<p>&#x68C0;&#x7D22;&#x6587;&#x672C;&#x5305;&#x542B;1000&#x7684;&#x6240;&#x6709;&#x884C;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name regexp <span class="hljs-string">&apos;1000&apos;</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<p>&#x4E0E;&#x4F7F;&#x7528;like&#x5173;&#x952E;&#x8BCD;&#x7684;&#x8BED;&#x53E5;&#x975E;&#x5E38;&#x50CF;&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7;&#x628A;like&#x6539;&#x4E3A;&#x4E86;regexp</p>
<p>==&#x4F46;&#x662F;like&#x5339;&#x914D;&#x6574;&#x4E2A;&#x5217;&#x503C;&#xFF0C;&#x4E00;&#x822C;&#x9700;&#x8981;&#x642D;&#x914D;&#x901A;&#x914D;&#x7B26;&#x4F7F;&#x7528;==</p>
<p>.000&#x4E2D; . &#x8868;&#x793A;&#x5339;&#x914D;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name regexp <span class="hljs-string">&apos;.000&apos;</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<p>&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#xFF0C;&#x5982;&#x679C;&#x9700;&#x8981;&#x533A;&#x5206;&#xFF0C;&#x5219;&#x5728;regexp&#x540E;&#x9762;&#x6DFB;&#x52A0;binary&#x5173;&#x952E;&#x5B57;</p>
<h4 id="&#x8FDB;&#x884C;or&#x5339;&#x914D;">&#x8FDB;&#x884C;OR&#x5339;&#x914D;</h4>
<blockquote>
<p>&#x641C;&#x7D22;&#x4E24;&#x4E2A;&#x4E32;&#x4E4B;&#x4E00;&#xFF0C;&#x4F7F;&#x7528;|&#xFF0C;&#x53EF;&#x4EE5;&#x7ED9;&#x51FA;&#x4E24;&#x4E2A;&#x4EE5;&#x4E0A;&#x7684;OR&#x6761;&#x4EF6;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name regexp <span class="hljs-string">&apos;1000|2000&apos;</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<h4 id="&#x5339;&#x914D;&#x51E0;&#x4E2A;&#x5B57;&#x7B26;&#x4E4B;&#x4E00;">&#x5339;&#x914D;&#x51E0;&#x4E2A;&#x5B57;&#x7B26;&#x4E4B;&#x4E00;</h4>
<blockquote>
<p>&#x4F7F;&#x7528;&#x4E00;&#x7EC4;&#x7528;[&#x548C;]&#x62EC;&#x8D77;&#x6765;&#x7684;&#x5B57;&#x7B26;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name regexp <span class="hljs-string">&apos;[123] Ton&apos;</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<p><sup><a href="#fn_123" id="reffn_123">123</a></sup>&#x5219;&#x5339;&#x914D;&#x9664;&#x8FD9;&#x4E9B;&#x5B57;&#x7B26;&#x4EE5;&#x5916;&#x7684;&#x4EFB;&#x610F;&#x5B57;&#x7B26;</p>
<h4 id="&#x5339;&#x914D;&#x8303;&#x56F4;">&#x5339;&#x914D;&#x8303;&#x56F4;</h4>
<p><strong>[0123456789]&#x53EF;&#x7B80;&#x5199;&#x4E3A;[0-9]</strong></p>
<h4 id="&#x5339;&#x914D;&#x7279;&#x6B8A;&#x5B57;&#x7B26;">&#x5339;&#x914D;&#x7279;&#x6B8A;&#x5B57;&#x7B26;</h4>
<pre><code class="lang-sql"><span class="hljs-comment">-- &#x52A0;\\&#x4E3A;&#x524D;&#x5BFC; \\-&#x8868;&#x793A;&#x67E5;&#x627E;- &#xFF0C; \\.&#x8868;&#x793A;&#x67E5;&#x627E;.</span>
</code></pre>
<table>
<thead>
<tr>
<th>&#x5143;&#x5B57;&#x7B26;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>\\f</td>
<td>&#x6362;&#x9875;</td>
</tr>
<tr>
<td>\\n</td>
<td>&#x6362;&#x884C;</td>
</tr>
<tr>
<td>\\r</td>
<td>&#x56DE;&#x8F66;</td>
</tr>
<tr>
<td>\\t</td>
<td>&#x5236;&#x8868;</td>
</tr>
<tr>
<td>\\v</td>
<td>&#x7EB5;&#x5411;&#x5236;&#x8868;</td>
</tr>
</tbody>
</table>
<p>==&#x4E3A;&#x4E86;&#x5339;&#x914D;\&#x672C;&#x8EAB;&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528;\\\==</p>
<h4 id="&#x5339;&#x914D;&#x5B57;&#x7B26;&#x7C7B;">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x7C7B;</h4>
<table>
<thead>
<tr>
<th>&#x7C7B;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>[:alnum:]</td>
<td>&#x4EFB;&#x610F;&#x5B57;&#x6BCD;&#x548C;&#x6570;&#x5B57;&#xFF08;&#x540C;[a-zA-Z0-9]&#xFF09;</td>
</tr>
<tr>
<td>[:alpha:]</td>
<td>&#x4EFB;&#x610F;&#x5B57;&#x7B26;&#xFF08;&#x540C;[a-zA-Z]&#xFF09;</td>
</tr>
<tr>
<td>[:blank:]</td>
<td>&#x7A7A;&#x683C;&#x548C;&#x5236;&#x8868;&#xFF08;&#x540C;[\\t]&#xFF09;</td>
</tr>
<tr>
<td>[:cntrl:]</td>
<td>ASCII&#x63A7;&#x5236;&#x5B57;&#x7B26;&#xFF08;ASCII0&#x5230;31&#x548C;127&#xFF09;</td>
</tr>
<tr>
<td>[:digit:]</td>
<td>&#x4EFB;&#x610F;&#x6570;&#x5B57;&#xFF08;&#x540C;[0-9]&#xFF09;</td>
</tr>
<tr>
<td>[:graph:]</td>
<td>&#x4E0E;[:print:]&#x76F8;&#x540C;&#xFF0C;&#x4F46;&#x4E0D;&#x5305;&#x542B;&#x7A7A;&#x683C;</td>
</tr>
<tr>
<td>[:lower:]</td>
<td>&#x4EFB;&#x610F;&#x5C0F;&#x5199;&#x5B57;&#x6BCD;&#xFF08;&#x540C;[a-z]&#xFF09;</td>
</tr>
<tr>
<td>[:print:]</td>
<td>&#x4EFB;&#x610F;&#x53EF;&#x6253;&#x5370;&#x5B57;&#x7B26;</td>
</tr>
<tr>
<td>[:punct:]</td>
<td>&#x65E2;&#x4E0D;&#x5728;[:alnum:]&#x53C8;&#x4E0D;&#x5728;[:cntrl:]&#x4E2D;&#x7684;&#x4EFB;&#x610F;&#x5B57;&#x7B26;</td>
</tr>
<tr>
<td>[:space:]</td>
<td>&#x5305;&#x62EC;&#x7A7A;&#x683C;&#x5728;&#x5185;&#x7684;&#x4EFB;&#x610F;&#x7A7A;&#x767D;&#x5B57;&#x7B26;&#xFF08;&#x540C;[\\\f\\n\\r\\t\\v]&#xFF09;</td>
</tr>
<tr>
<td>[:upper:]</td>
<td>&#x4EFB;&#x610F;&#x5927;&#x5199;&#x5B57;&#x6BCD;&#xFF08;&#x540C;[A-Z]&#xFF09;</td>
</tr>
<tr>
<td>[:xdigit:]</td>
<td>&#x4EFB;&#x610F;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x6570;&#x5B57;&#xFF08;&#x540C;[a-fA-F0-9]&#xFF09;</td>
</tr>
</tbody>
</table>
<h4 id="&#x5339;&#x914D;&#x591A;&#x4E2A;&#x5B9E;&#x4F8B;">&#x5339;&#x914D;&#x591A;&#x4E2A;&#x5B9E;&#x4F8B;</h4>
<table>
<thead>
<tr>
<th>&#x5143;&#x5B57;&#x7B26;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>*</td>
<td>0&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x5339;&#x914D;</td>
</tr>
<tr>
<td>+</td>
<td>1&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x5339;&#x914D;&#xFF08;&#x7B49;&#x4E8E;{1,}&#xFF09;</td>
</tr>
<tr>
<td>?</td>
<td>0&#x4E2A;&#x6216;1&#x4E2A;&#x5339;&#x914D;&#xFF08;&#x7B49;&#x4E8E;{0,1}&#xFF09;</td>
</tr>
<tr>
<td>{n}</td>
<td>&#x6307;&#x5B9A;&#x6570;&#x76EE;&#x7684;&#x5339;&#x914D;</td>
</tr>
<tr>
<td>{n,}</td>
<td>&#x4E0D;&#x5C11;&#x4E8E;&#x6307;&#x5B9A;&#x6570;&#x76EE;&#x7684;&#x5339;&#x914D;</td>
</tr>
<tr>
<td>{n,m}</td>
<td>&#x5339;&#x914D;&#x6570;&#x76EE;&#x7684;&#x8303;&#x56F4;&#xFF08;m&#x4E0D;&#x8D85;&#x8FC7;255&#xFF09;</td>
</tr>
</tbody>
</table>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name regexp <span class="hljs-string">&apos;\\([0-9] sticks?\\)&apos;</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<p>&#x8F93;&#x51FA;&#x793A;&#x4F8B;</p>
<pre><code>TNT (1 stick)
TNT (5 sticks)
</code></pre><p>&#x5206;&#x6790;&#xFF1A;\\( &#x5339;&#x914D; ( ,[0-9]&#x5339;&#x914D;&#x4EFB;&#x610F;&#x6570;&#x5B57;&#xFF0C;sticks?&#x5339;&#x914D;stick&#x548C;sticks&#xFF0C;\\)&#x5339;&#x914D;)</p>
<h4 id="&#x5B9A;&#x4F4D;&#x7B26;">&#x5B9A;&#x4F4D;&#x7B26;</h4>
<table>
<thead>
<tr>
<th>&#x5143;&#x5B57;&#x7B26;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>^</td>
<td>&#x6587;&#x672C;&#x7684;&#x5F00;&#x59CB;</td>
</tr>
<tr>
<td>$</td>
<td>&#x6587;&#x672C;&#x7684;&#x7ED3;&#x5C3E;</td>
</tr>
<tr>
<td>[[:&lt;:]]</td>
<td>&#x8BCD;&#x7684;&#x5F00;&#x59CB;</td>
</tr>
<tr>
<td>[[:&gt;:]]</td>
<td>&#x8BCD;&#x7684;&#x7ED3;&#x5C3E;</td>
</tr>
</tbody>
</table>
<p>&#x5982;&#x679C;&#x60F3;&#x8981;&#x627E;&#x51FA;&#x4EE5;&#x4E00;&#x4E2A;&#x6570;&#xFF08;&#x5305;&#x62EC;&#x4EE5;&#x5C0F;&#x6570;&#x70B9;&#x5F00;&#x59CB;&#x7684;&#x6570;&#xFF09;<strong>&#x5F00;&#x59CB;</strong>&#x7684;&#x6240;&#x6709;&#x4EA7;&#x54C1;&#xFF0C;&#x4F7F;&#x7528;[0-9\\.]&#x4E0D;&#x884C;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x5728;&#x6587;&#x672C;&#x5185;&#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x67E5;&#x627E;&#x5339;&#x914D;&#x3002;&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#x662F;&#x4F7F;&#x7528;&#x5B9A;&#x4F4D;&#x7B26;^</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_name <span class="hljs-keyword">from</span> products <span class="hljs-keyword">where</span> prod_name regexp <span class="hljs-string">&apos;^[0-9\\.]&apos;</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> prod_name;
</code></pre>
<p><strong>^&#x7684;&#x53CC;&#x91CD;&#x7528;&#x9014;</strong>&#xFF1A;&#x5728;&#x96C6;&#x5408;&#x4E2D;&#xFF0C;&#x7528;&#x5B83;&#x6765;&#x5426;&#x5B9A;&#x8BE5;&#x96C6;&#x5408;&#xFF0C;&#x5426;&#x5219;&#x7528;&#x6765;&#x6307;&#x4E32;&#x7684;&#x5F00;&#x59CB;&#x5904;</p>
<h3 id="&#x521B;&#x5EFA;&#x8BA1;&#x7B97;&#x5B57;&#x6BB5;">&#x521B;&#x5EFA;&#x8BA1;&#x7B97;&#x5B57;&#x6BB5;</h3>
<blockquote>
<p>&#x8BA1;&#x7B97;&#x5B57;&#x6BB5;&#x5E76;&#x4E0D;&#x5B9E;&#x9645;&#x5B58;&#x5728;&#x4E8E;&#x6570;&#x636E;&#x5E93;&#x8868;&#x4E2D;&#x3002;&#x8BA1;&#x7B97;&#x5B57;&#x6BB5;&#x662F;&#x8FD0;&#x884C;&#x65F6;&#x5728;SELECT&#x8BED;&#x53E5;&#x5185;&#x521B;&#x5EFA;&#x7684;&#x3002;</p>
</blockquote>
<p><strong>&#x5B57;&#x6BB5;</strong>&#xFF1A;&#x57FA;&#x672C;&#x4E0A;&#x4E0E;&#x5217;&#x7684;&#x610F;&#x601D;&#x76F8;&#x540C;</p>
<h4 id="&#x62FC;&#x63A5;&#x5B57;&#x6BB5;">&#x62FC;&#x63A5;&#x5B57;&#x6BB5;</h4>
<blockquote>
<p>&#x62FC;&#x63A5;&#xFF1A;&#x5C06;&#x503C;&#x8054;&#x7ED3;&#x5230;&#x4E00;&#x8D77;&#x6784;&#x6210;&#x5355;&#x4E2A;&#x503C;</p>
</blockquote>
<p>&#x5728;MySQL&#x7684;SELECT&#x8BED;&#x53E5;&#x4E2D;&#xFF0C;&#x53EF;&#x4F7F;&#x7528;<strong>==Concat()&#x51FD;&#x6570;==</strong>&#x6765;&#x62FC;&#x63A5;&#x4E24;&#x4E2A;&#x5217;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> <span class="hljs-keyword">Concat</span>(vend_name,<span class="hljs-string">&apos;(&apos;</span>,vend_country,<span class="hljs-string">&apos;)&apos;</span>) <span class="hljs-keyword">from</span> vendors <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> vend_name;
</code></pre>
<p>Trim()&#x51FD;&#x6570;&#xFF1A;&#x53BB;&#x9664;&#x4E32;&#x5DE6;&#x53F3;&#x4E24;&#x8FB9;&#x7684;&#x7A7A;&#x683C;</p>
<p>LTrim()&#xFF1A;&#x53BB;&#x9664;&#x5DE6;&#x8FB9;&#x7684;&#x7A7A;&#x683C;    RTrim()&#xFF1A;&#x53BB;&#x9664;&#x53F3;&#x8FB9;&#x7684;&#x7A7A;&#x683C;</p>
<p><strong>&#x4F7F;&#x7528;&#x522B;&#x540D;</strong></p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> <span class="hljs-keyword">Concat</span>(vend_name,<span class="hljs-string">&apos;(&apos;</span>,vend_country,<span class="hljs-string">&apos;)&apos;</span>) <span class="hljs-keyword">as</span> vend_title <span class="hljs-keyword">from</span> vendors <span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> vend_name;
</code></pre>
<h4 id="&#x6267;&#x884C;&#x7B97;&#x672F;&#x8BA1;&#x7B97;">&#x6267;&#x884C;&#x7B97;&#x672F;&#x8BA1;&#x7B97;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> prod_id,
       quantity,
       item_price,
       quantity*item_price <span class="hljs-keyword">AS</span> expanded_price
<span class="hljs-keyword">from</span> orderitems
<span class="hljs-keyword">where</span> order_num = <span class="hljs-number">20005</span>;
</code></pre>
<h3 id="&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5904;&#x7406;&#x51FD;&#x6570;">&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5904;&#x7406;&#x51FD;&#x6570;</h3>
<h4 id="&#x6587;&#x672C;&#x5904;&#x7406;&#x51FD;&#x6570;">&#x6587;&#x672C;&#x5904;&#x7406;&#x51FD;&#x6570;</h4>
<ol>
<li>Trim() </li>
<li>Upper()</li>
<li>Lower()</li>
<li>Soundex()&#xFF1A;&#x8FD4;&#x56DE;&#x4E32;&#x7684;soundex&#x503C;&#xFF0C;&#x80FD;&#x5BF9;&#x4E32;&#x8FDB;&#x884C;&#x53D1;&#x97F3;&#x6BD4;&#x8F83;</li>
<li>&#x2026;&#x2026;</li>
</ol>
<h4 id="&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x5904;&#x7406;&#x51FD;&#x6570;">&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x5904;&#x7406;&#x51FD;&#x6570;</h4>
<p>&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x5FC5;&#x987B;&#x4E3A;yyyy-mm-dd</p>
<p>MySQL&#x4E2D;&#x5B58;&#x5728;&#x7C7B;&#x578B;datetime&#xFF0C;&#x683C;&#x5F0F;&#x4E3A;&#xFF1A;yyyy-MM-dd HH:mm:ss</p>
<p>&#x5982;&#x679C;&#x8981;&#x7684;&#x53EA;&#x662F;&#x65E5;&#x671F;&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528;Date()&#x51FD;&#x6570;&#xFF0C;&#x4E5F;&#x5B58;&#x5728;&#x4E00;&#x4E2A;Time()&#x51FD;&#x6570;</p>
<h4 id="&#x6570;&#x503C;&#x5904;&#x7406;&#x51FD;&#x6570;">&#x6570;&#x503C;&#x5904;&#x7406;&#x51FD;&#x6570;</h4>
<ol>
<li>Abs()</li>
<li>Cos()</li>
<li>Exp()</li>
<li>Mod()</li>
<li>&#x2026;&#x2026;</li>
</ol>
<h3 id="&#x6C47;&#x603B;&#x6570;&#x636E;">&#x6C47;&#x603B;&#x6570;&#x636E;</h3>
<h4 id="&#x805A;&#x96C6;&#x51FD;&#x6570;">&#x805A;&#x96C6;&#x51FD;&#x6570;</h4>
<blockquote>
<p>&#x8FD0;&#x884C;&#x5728;&#x884C;&#x7EC4;&#x4E0A;&#xFF0C;&#x8BA1;&#x7B97;&#x548C;&#x8FD4;&#x56DE;&#x5355;&#x4E2A;&#x503C;&#x7684;&#x51FD;&#x6570;</p>
</blockquote>
<h5 id="avg">AVG()</h5>
<blockquote>
<p>&#x8FD4;&#x56DE;&#x67D0;&#x5217;&#x7684;&#x5E73;&#x5747;&#x503C;</p>
</blockquote>
<p>&#x5FFD;&#x7565;&#x5217;&#x503C;&#x4E3A;null&#x7684;&#x884C;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> <span class="hljs-keyword">AVG</span>(prod_price) <span class="hljs-keyword">AS</span> avg_price <span class="hljs-keyword">FROM</span> products;
</code></pre>
<h5 id="count">COUNT()</h5>
<blockquote>
<p>&#x8FD4;&#x56DE;&#x67D0;&#x5217;&#x7684;&#x884C;&#x6570;</p>
</blockquote>
<p>&#x5982;&#x679C;&#x6307;&#x5B9A;&#x5217;&#x540D;&#xFF0C;&#x503C;&#x4E3A;null&#x7684;&#x884C;&#x5C06;&#x88AB;&#x5FFD;&#x7565;&#x3002;&#x5982;&#x679C;&#x4F7F;&#x7528;COUNT(*)&#xFF0C;&#x5219;&#x4E0D;&#x5FFD;&#x7565;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> <span class="hljs-keyword">COUNT</span>(*) <span class="hljs-keyword">AS</span> num_cust <span class="hljs-keyword">FROM</span> customers;
</code></pre>
<h5 id="max">MAX()</h5>
<blockquote>
<p>&#x8FD4;&#x56DE;&#x67D0;&#x5217;&#x7684;&#x6700;&#x5927;&#x503C;&#xFF0C;&#x5FFD;&#x7565;&#x503C;&#x4E3A;null&#x7684;&#x884C;</p>
</blockquote>
<p>&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x6570;&#x503C;&#x6216;&#x65E5;&#x671F;&#x503C;&#x3002;&#x5728;&#x7528;&#x4E8E;&#x6587;&#x672C;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x6570;&#x636E;&#x6309;&#x76F8;&#x5E94;&#x5217;&#x6392;&#x5E8F;&#xFF0C;&#x5219;MAX()&#x8FD4;&#x56DE;&#x6700;&#x540E;&#x4E00;&#x884C;</p>
<h5 id="mix">MIX()</h5>
<blockquote>
<p>&#x8FD4;&#x56DE;&#x67D0;&#x5217;&#x7684;&#x6700;&#x5C0F;&#x503C;,&#x4E0E;MAX&#x76F8;&#x53CD;</p>
</blockquote>
<h5 id="sun">SUN()</h5>
<blockquote>
<p>&#x8FD4;&#x56DE;&#x67D0;&#x5217;&#x503C;&#x503C;&#x548C;</p>
</blockquote>
<h4 id="&#x805A;&#x96C6;&#x4E0D;&#x540C;&#x503C;">&#x805A;&#x96C6;&#x4E0D;&#x540C;&#x503C;</h4>
<p>ALL&#x4E3A;&#x9ED8;&#x8BA4;&#xFF0C;&#x5BF9;&#x6240;&#x6709;&#x7684;&#x884C;&#x6267;&#x884C;&#x64CD;&#x4F5C;</p>
<p>DISTINCT&#xFF0C;&#x53EA;&#x5305;&#x542B;&#x4E0D;&#x540C;&#x7684;&#x503C;</p>
<h4 id="&#x7EC4;&#x5408;&#x805A;&#x96C6;&#x51FD;&#x6570;">&#x7EC4;&#x5408;&#x805A;&#x96C6;&#x51FD;&#x6570;</h4>
<p>&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x4F7F;&#x7528;&#x591A;&#x4E2A;&#x805A;&#x96C6;&#x51FD;&#x6570;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> <span class="hljs-keyword">COUNT</span>(*) <span class="hljs-keyword">AS</span> num_item,
       <span class="hljs-keyword">MIN</span>(prod_price) <span class="hljs-keyword">AS</span> price_min,
       <span class="hljs-keyword">MAX</span>(prod_price) <span class="hljs-keyword">AS</span> price_max,
       <span class="hljs-keyword">AVG</span>(prod_price) <span class="hljs-keyword">AS</span> price_avg
<span class="hljs-keyword">from</span> products;
</code></pre>
<h5 id="&#x53D6;&#x522B;&#x540D;">&#x53D6;&#x522B;&#x540D;</h5>
<blockquote>
<p>&#x4E0D;&#x5E94;&#x8BE5;&#x4F7F;&#x7528;&#x8868;&#x4E2D;&#x5B9E;&#x9645;&#x7684;&#x5217;&#x540D;&#x3002;&#x5E76;&#x975E;&#x4E0D;&#x5408;&#x6CD5;&#xFF0C;&#x4F46;&#x662F;&#x4F7F;&#x7528;&#x552F;&#x4E00;&#x7684;&#x540D;&#x5B57;&#x4F1A;&#x4F7F;SQL&#x66F4;&#x6613;&#x4E8E;&#x7406;&#x89E3;</p>
</blockquote>
<h3 id="&#x5206;&#x7EC4;&#x6570;&#x636E;">&#x5206;&#x7EC4;&#x6570;&#x636E;</h3>
<h4 id="group-by&#x5B50;&#x53E5;">GROUP BY&#x5B50;&#x53E5;</h4>
<blockquote>
<p>group by&#x5B50;&#x53E5;&#x6307;&#x793A;MySQL&#x5206;&#x7EC4;&#x6570;&#x636E;&#xFF0C;&#x7136;&#x540E;&#x5BF9;&#x6BCF;&#x4E2A;&#x7EC4;&#x800C;&#x4E0D;&#x662F;&#x6574;&#x4E2A;&#x7ED3;&#x679C;&#x96C6;&#x8FDB;&#x884C;&#x805A;&#x96C6;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> vend_id, <span class="hljs-keyword">COUNT</span>(*) <span class="hljs-keyword">AS</span> num_prods <span class="hljs-keyword">FROM</span> products <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> vend_id;
</code></pre>
<p>&#x91CD;&#x8981;&#x89C4;&#x5B9A;</p>
<ul>
<li>group by&#x5B50;&#x53E5;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x4EFB;&#x610F;&#x6570;&#x76EE;&#x7684;&#x5217;</li>
<li>&#x5982;&#x679C;&#x5728;group by&#x5B50;&#x53E5;&#x4E2D;&#x5D4C;&#x5957;&#x4E86;&#x5206;&#x7EC4;&#xFF0C;&#x6570;&#x636E;&#x5C06;&#x5728;&#x6700;&#x540E;&#x89C4;&#x5B9A;&#x7684;&#x5206;&#x7EC4;&#x4E0A;&#x8FDB;&#x884C;&#x6C47;&#x603B;</li>
<li>group by&#x5B50;&#x53E5;&#x4E2D;&#x5217;&#x51FA;&#x7684;&#x6BCF;&#x4E2A;&#x5217;&#x90FD;&#x5FC5;&#x987B;&#x662F;&#x68C0;&#x7D22;&#x5217;&#x6216;&#x6709;&#x6548;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF08;&#x4F46;&#x662F;&#x4E0D;&#x80FD;&#x662F;&#x805A;&#x96C6;&#x51FD;&#x6570;&#xFF09;</li>
<li>&#x9664;&#x805A;&#x96C6;&#x8BA1;&#x7B97;&#x8BED;&#x53E5;&#x5916;&#xFF0C;select&#x8BED;&#x53E5;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x5217;&#x90FD;&#x5FC5;&#x987B;&#x5728;group by&#x5B50;&#x53E5;&#x4E2D;&#x7ED9;&#x51FA;</li>
<li>&#x5982;&#x679C;&#x5206;&#x7EC4;&#x5217;&#x4E2D;&#x5177;&#x6709;null&#x503C;&#xFF0C;&#x5219;null&#x5C06;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x5206;&#x7EC4;&#x8FD4;&#x56DE;</li>
<li>group by&#x5B50;&#x53E5;&#x5FC5;&#x987B;&#x51FA;&#x73B0;&#x5728;where&#x5B50;&#x53E5;&#x4E4B;&#x540E;&#xFF0C;order by&#x5B50;&#x53E5;&#x4E4B;&#x524D;</li>
</ul>
<p><strong>&#x4F7F;&#x7528;ROLLUP</strong>&#xFF1A;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;with rollup&#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x6BCF;&#x4E2A;&#x5206;&#x7EC4;&#x4EE5;&#x53CA;&#x6BCF;&#x4E2A;&#x5206;&#x7EC4;&#x6C47;&#x603B;&#x7EA7;&#x522B;&#x7684;&#x503C;</p>
<h4 id="&#x8FC7;&#x6EE4;&#x5206;&#x7EC4;">&#x8FC7;&#x6EE4;&#x5206;&#x7EC4;</h4>
<p>where&#x8FC7;&#x6EE4;&#x6307;&#x5B9A;&#x7684;&#x662F;&#x884C;&#x800C;&#x4E0D;&#x662F;&#x5206;&#x7EC4;</p>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;having&#x5B50;&#x53E5;&#x8FC7;&#x6EE4;&#x5206;&#x7EC4;&#xFF0C;having&#x652F;&#x6301;&#x6240;&#x6709;where&#x64CD;&#x4F5C;&#x7B26;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> cust_id, <span class="hljs-keyword">COUNT</span>(*) <span class="hljs-keyword">AS</span> orders <span class="hljs-keyword">FROM</span> orders <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> cust_id <span class="hljs-keyword">HAVING</span> <span class="hljs-keyword">COUNT</span>(*)&gt;=<span class="hljs-number">2</span>;
</code></pre>
<h4 id="&#x5206;&#x7EC4;&#x548C;&#x6392;&#x5E8F;">&#x5206;&#x7EC4;&#x548C;&#x6392;&#x5E8F;</h4>
<p><strong>&#x4E00;&#x822C;&#x5728;&#x4F7F;&#x7528;group by&#x5B50;&#x53E5;&#x65F6;&#xFF0C;&#x5E94;&#x8BE5;&#x4E5F;&#x7ED9;&#x51FA;order by&#x5B50;&#x53E5;</strong></p>
<h4 id="select&#x5B50;&#x53E5;&#x987A;&#x5E8F;">select&#x5B50;&#x53E5;&#x987A;&#x5E8F;</h4>
<p>select&#x2192;from&#x2192;where&#x2192;group by&#x2192;having&#x2192;order by&#x2192;limit</p>
<h3 id="&#x4F7F;&#x7528;&#x5B50;&#x67E5;&#x8BE2;">&#x4F7F;&#x7528;&#x5B50;&#x67E5;&#x8BE2;</h3>
<blockquote>
<p>&#x5B50;&#x67E5;&#x8BE2;&#xFF1A;&#x5D4C;&#x5957;&#x5728;&#x5176;&#x4ED6;&#x67E5;&#x8BE2;&#x91CC;&#x7684;&#x67E5;&#x8BE2;</p>
</blockquote>
<p>&#x5B50;&#x67E5;&#x8BE2;&#x603B;&#x662F;&#x4ECE;&#x5185;&#x5411;&#x5916;&#x5904;&#x7406;</p>
<p>&#x4E00;&#x822C;&#x4E0E;IN&#x64CD;&#x4F5C;&#x7B26;&#x7ED3;&#x5408;&#x4F7F;&#x7528;</p>
<p>&#x4EE5;&#x4E0B;&#x4E24;&#x6761;&#x8BED;&#x53E5;&#x53EF;&#x5408;&#x5E76;&#x4E3A;&#x4E00;&#x6761;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> order_num <span class="hljs-keyword">from</span> orderitems <span class="hljs-keyword">where</span> prod_id = <span class="hljs-string">&apos;TNT2&apos;</span>; <span class="hljs-comment">-- &#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x4E3A; 20005 20007</span>
<span class="hljs-keyword">SELECT</span> cust_id <span class="hljs-keyword">from</span> orders <span class="hljs-keyword">where</span> order_num <span class="hljs-keyword">IN</span>(<span class="hljs-number">20005</span>,<span class="hljs-number">20007</span>);  <span class="hljs-comment">-- &#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x4E3A;10001 10004</span>
</code></pre>
<p>&#x4F7F;&#x7528;&#x5B50;&#x67E5;&#x8BE2;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> cust_id 
<span class="hljs-keyword">from</span> orders 
<span class="hljs-keyword">where</span> order_num <span class="hljs-keyword">IN</span>(<span class="hljs-keyword">SELECT</span> order_num 
                   <span class="hljs-keyword">from</span> orderitems 
                   <span class="hljs-keyword">where</span> prod_id = <span class="hljs-string">&apos;TNT2&apos;</span>);
</code></pre>
<h3 id="&#x8FDE;&#x7ED3;&#x8868;">&#x8FDE;&#x7ED3;&#x8868;</h3>
<blockquote>
<p>&#x8054;&#x7ED3;&#x662F;&#x5229;&#x7528;SQL&#x7684;select&#x80FD;&#x6267;&#x884C;&#x7684;&#x6700;&#x91CD;&#x8981;&#x7684;&#x64CD;&#x4F5C;</p>
</blockquote>
<p>&#x4E3B;&#x952E;</p>
<p>&#x5916;&#x952E;</p>
<p>&#x6D89;&#x53CA;&#x4E24;&#x4E2A;&#x8868;&#x7684;&#x67E5;&#x8BE2;&#xFF0C;&#x5728;&#x5F15;&#x7528;&#x7684;&#x5217;&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x4E8C;&#x4E49;&#x6027;&#x65F6;&#xFF0C;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x5B8C;&#x5168;&#x9650;&#x5B9A;&#x5217;&#x540D;&#x3002;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> vend_name, prod_name, prod_price
<span class="hljs-keyword">from</span> vendors, products
<span class="hljs-keyword">where</span> venders.vend_id = products.vend_id
<span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> vend_name, prod_name;
</code></pre>
<p>&#x5982;&#x679C;&#x4E0D;&#x4F7F;&#x7528;where&#x5B50;&#x53E5;&#x5EFA;&#x7ACB;&#x8054;&#x7ED3;&#x6761;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x8FD4;&#x56DE;&#x7684;&#x7ED3;&#x679C;&#x4E3A;&#x7B1B;&#x5361;&#x5C14;&#x79EF;&#x3002;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> vend_name, prod_name, prod_price
<span class="hljs-keyword">from</span> vendors, products
<span class="hljs-keyword">order</span> <span class="hljs-keyword">by</span> vend_name, prod_name;
</code></pre>
<p>==&#x5E94;&#x8BE5;&#x4FDD;&#x8BC1;&#x6240;&#x6709;&#x7684;&#x8054;&#x7ED3;&#x90FD;&#x6709;where&#x5B50;&#x53E5;==</p>
<h4 id="&#x5185;&#x90E8;&#x8054;&#x7ED3;">&#x5185;&#x90E8;&#x8054;&#x7ED3;</h4>
<blockquote>
<p>&#x5185;&#x90E8;&#x8054;&#x7ED3;&#xFF0C;&#x4E5F;&#x79F0;&#x4E3A;&#x7B49;&#x503C;&#x8054;&#x7ED3;&#xFF0C;&#x57FA;&#x4E8E;&#x4E24;&#x8868;&#x4E4B;&#x95F4;&#x7684;&#x76F8;&#x7B49;&#x6D4B;&#x8BD5;</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> vend_name, prod_name, prod_price
<span class="hljs-keyword">from</span> vendors <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> products
<span class="hljs-keyword">ON</span> venders.vend_id = products.vend_id;
</code></pre>
<p>&#x4F7F;&#x7528;<code>INNER JOIN</code>&#x4E4B;&#x540E;&#xFF0C;&#x7528;<code>ON</code>&#x5B50;&#x53E5;&#x6307;&#x5B9A;&#x8054;&#x7ED3;&#x6761;&#x4EF6;</p>
<h4 id="&#x8054;&#x7ED3;&#x591A;&#x4E2A;&#x8868;">&#x8054;&#x7ED3;&#x591A;&#x4E2A;&#x8868;</h4>
<p>&#x8054;&#x7ED3;&#x7684;&#x8868;&#x8D8A;&#x591A;&#xFF0C;&#x6027;&#x80FD;&#x4E0B;&#x964D;&#x7684;&#x8D8A;&#x5389;&#x5BB3;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">select</span> vend_name, prod_name, prod_price, quantity
<span class="hljs-keyword">from</span> vendors, products,orderitems
<span class="hljs-keyword">where</span> venders.vend_id = products.vend_id
  <span class="hljs-keyword">AND</span> orderitems.prod_id = products.prod_id
  <span class="hljs-keyword">AND</span> order_num = <span class="hljs-number">20005</span>;
</code></pre>
<h3 id="&#x521B;&#x5EFA;&#x9AD8;&#x7EA7;&#x8054;&#x7ED3;">&#x521B;&#x5EFA;&#x9AD8;&#x7EA7;&#x8054;&#x7ED3;</h3>
<h4 id="&#x4F7F;&#x7528;&#x8868;&#x522B;&#x540D;">&#x4F7F;&#x7528;&#x8868;&#x522B;&#x540D;</h4>
<ul>
<li>&#x7F29;&#x77ED;SQL&#x8BED;&#x53E5;</li>
<li>&#x5141;&#x8BB8;&#x5355;&#x6761;SELECT&#x8BED;&#x53E5;&#x4E2D;&#x591A;&#x6B21;&#x4F7F;&#x7528;&#x76F8;&#x540C;&#x8868;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> cust_name, cust_contact
<span class="hljs-keyword">FROM</span> customers <span class="hljs-keyword">AS</span> c, orders <span class="hljs-keyword">AS</span> o, orderitems <span class="hljs-keyword">AS</span> oi
<span class="hljs-keyword">WHERE</span> c.cust_id = o.cust_id
  <span class="hljs-keyword">AND</span> oi.order_num = o.order_num
  <span class="hljs-keyword">AND</span> prod_id = <span class="hljs-string">&apos;TNT2&apos;</span>;
</code></pre>
<h4 id="&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x8054;&#x7ED3;">&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x8054;&#x7ED3;</h4>
<h5 id="&#x81EA;&#x8054;&#x7ED3;">&#x81EA;&#x8054;&#x7ED3;</h5>
<p>&#x5047;&#x5982;&#x53D1;&#x73B0;&#x67D0;&#x7269;&#x54C1;&#xFF08;&#x5176;ID&#x4E3A;DTNTR&#xFF09;&#x5B58;&#x5728;&#x95EE;&#x9898;&#xFF0C;&#x56E0;&#x6B64;&#x60F3;&#x77E5;&#x9053;&#x751F;&#x4EA7;&#x8BE5;&#x7269;&#x54C1;&#x7684;&#x4F9B;&#x5E94;&#x5546;&#x751F;&#x4EA7;&#x7684;&#x5176;&#x4ED6;&#x7269;&#x54C1;&#x662F;&#x5426;&#x5B58;&#x5728;&#x95EE;&#x9898;&#x3002;</p>
<p>&#x4F7F;&#x7528;&#x5B50;&#x67E5;&#x8BE2;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> prod_id, prod_name
<span class="hljs-keyword">FROM</span> products
<span class="hljs-keyword">WHERE</span> vend_id = (<span class="hljs-keyword">SELECT</span> vend_id
                 <span class="hljs-keyword">FROM</span> products
                 <span class="hljs-keyword">WHERE</span> prod_id = <span class="hljs-string">&apos;DTNTR&apos;</span>);
</code></pre>
<p>&#x4F7F;&#x7528;&#x8054;&#x7ED3;&#x7684;&#x76F8;&#x540C;&#x67E5;&#x8BE2;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> prod_id, prod_name
<span class="hljs-keyword">FROM</span> products <span class="hljs-keyword">AS</span> p1, products <span class="hljs-keyword">AS</span> p2
<span class="hljs-keyword">WHERE</span> p1.vend_id = p2.vend_id
  <span class="hljs-keyword">AND</span> p2.prod_id = <span class="hljs-string">&apos;DTNTR&apos;</span>;
</code></pre>
<p>&#x6B64;&#x67E5;&#x8BE2;&#x4E2D;&#x9700;&#x8981;&#x7684;&#x4E24;&#x4E2A;&#x8868;&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x76F8;&#x540C;&#x7684;&#x8868;&#xFF0C;&#x901A;&#x8FC7;&#x4F7F;&#x7528;&#x522B;&#x540D;&#x907F;&#x514D;&#x4E8C;&#x4E49;&#x6027;&#x3002;</p>
<p>&#x4F7F;&#x7528;&#x81EA;&#x8054;&#x7ED3;&#x6BD4;&#x5B50;&#x67E5;&#x8BE2;&#x6548;&#x7387;&#x66F4;&#x9AD8;&#x3002;</p>
<h5 id="&#x81EA;&#x7136;&#x8054;&#x7ED3;">&#x81EA;&#x7136;&#x8054;&#x7ED3;</h5>
<blockquote>
<p>&#x5BF9;&#x8868;&#x8FDB;&#x884C;&#x8054;&#x7ED3;&#xFF0C;&#x5E94;&#x8BE5;&#x81F3;&#x5C11;&#x6709;&#x4E00;&#x4E2A;&#x5217;&#x51FA;&#x73B0;&#x5728;&#x4E0D;&#x6B62;&#x4E00;&#x4E2A;&#x8868;&#x4E2D;&#xFF0C;&#x6807;&#x51C6;&#x7684;&#x8054;&#x7ED3;&#x8FD4;&#x56DE;&#x6240;&#x6709;&#x6570;&#x636E;&#xFF0C;&#x751A;&#x81F3;&#x76F8;&#x540C;&#x7684;&#x5217;&#x591A;&#x6B21;&#x51FA;&#x73B0;&#x3002;&#x81EA;&#x7136;&#x8054;&#x7ED3;&#x6392;&#x9664;&#x591A;&#x6B21;&#x51FA;&#x73B0;&#xFF0C;&#x4F7F;&#x6BCF;&#x4E2A;&#x5217;&#x53EA;&#x8FD4;&#x56DE;&#x4E00;&#x6B21;</p>
</blockquote>
<p>&#x4E00;&#x822C;&#x901A;&#x8FC7;&#x5BF9;&#x8868;&#x4F7F;&#x7528;&#x901A;&#x914D;&#x7B26;(SELECT *)&#xFF0C;&#x5BF9;&#x5176;&#x4ED6;&#x8868;&#x7684;&#x5217;&#x4F7F;&#x7528;&#x660E;&#x786E;&#x7684;&#x5B50;&#x96C6;&#x6765;&#x5B8C;&#x6210;&#x3002;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> c.*, o.order_num, o.order_date, oi.prod_id, oi.quantity, oi.item_price
<span class="hljs-keyword">FROM</span> customers <span class="hljs-keyword">AS</span> c, orders <span class="hljs-keyword">AS</span> o, orderitem <span class="hljs-keyword">AS</span> oi
<span class="hljs-keyword">WHERE</span> c.cust_id = o.cust_id
  <span class="hljs-keyword">AND</span> oi.order_num = o.order_num
  <span class="hljs-keyword">AND</span> prod_id = <span class="hljs-string">&apos;FB&apos;</span>;
</code></pre>
<p>&#x901A;&#x914D;&#x7B26;&#x53EA;&#x5BF9;&#x7B2C;&#x4E00;&#x4E2A;&#x8868;&#x4F7F;&#x7528;&#x3002;&#x6240;&#x6709;&#x5176;&#x4ED6;&#x5217;&#x660E;&#x786E;&#x5217;&#x51FA;&#xFF0C;&#x6240;&#x4EE5;&#x6CA1;&#x6709;&#x91CD;&#x590D;&#x7684;&#x5217;&#x88AB;&#x68C0;&#x7D22;&#x51FA;&#x6765;&#x3002;</p>
<h5 id="&#x5916;&#x90E8;&#x8054;&#x7ED3;">&#x5916;&#x90E8;&#x8054;&#x7ED3;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> customers.cust_id, <span class="hljs-keyword">order</span>.order_num
<span class="hljs-keyword">FROM</span> customers <span class="hljs-keyword">LEFT</span> <span class="hljs-keyword">OUTER</span> <span class="hljs-keyword">JOIN</span> orders
<span class="hljs-keyword">ON</span> customers.cust_id = orders.cust_id;
</code></pre>
<p>&#x4F7F;&#x7528;&#x4E86;<code>OUTER JOIN</code>&#x6765;&#x6307;&#x5B9A;&#x8054;&#x7ED3;&#x7684;&#x7C7B;&#x578B;&#x3002;&#x4E0E;&#x5185;&#x90E8;&#x8054;&#x7ED3;&#x4E0D;&#x540C;&#x7684;&#x662F;&#x5916;&#x90E8;&#x8054;&#x7ED3;&#x8FD8;&#x5305;&#x62EC;&#x6CA1;&#x6709;&#x5173;&#x8054;&#x7684;&#x884C;&#x3002;</p>
<p>&#x4F7F;&#x7528;LEFT&#x6216;RIGHT&#x5173;&#x952E;&#x8BCD;&#x6307;&#x5B9A;&#x5305;&#x62EC;&#x5176;&#x6240;&#x6709;&#x884C;&#x7684;&#x8868;</p>
<p>&#x4E0A;&#x9762;&#x4F8B;&#x5B50;&#x4E2D;&#x4F7F;&#x7528;LEFT OUTER JOIN &#x4ECE;customers&#x8868;&#x4E2D;&#x9009;&#x62E9;&#x6240;&#x6709;&#x884C;&#xFF0C;&#x5373;&#x5DE6;&#xFF08;&#x5916;&#xFF09;&#x8FDE;&#x63A5;</p>
<p>&#x4E0B;&#x9762;&#x5C55;&#x793A;&#x53F3;&#xFF08;&#x5916;&#xFF09;&#x8FDE;&#x63A5;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> customers.cust_id, <span class="hljs-keyword">order</span>.order_num
<span class="hljs-keyword">FROM</span> customers <span class="hljs-keyword">RIGHT</span> <span class="hljs-keyword">OUTER</span> <span class="hljs-keyword">JOIN</span> orders
<span class="hljs-keyword">ON</span> customers.cust_id = orders.cust_id;
</code></pre>
<h4 id="&#x4F7F;&#x7528;&#x5E26;&#x805A;&#x96C6;&#x51FD;&#x6570;&#x7684;&#x8054;&#x7ED3;">&#x4F7F;&#x7528;&#x5E26;&#x805A;&#x96C6;&#x51FD;&#x6570;&#x7684;&#x8054;&#x7ED3;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> customers.cust_name,
       customers.cust_id,
       <span class="hljs-keyword">COUNT</span>(orders.order_num) <span class="hljs-keyword">AS</span> num_ord
<span class="hljs-keyword">FROM</span> customers <span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> orders
<span class="hljs-keyword">ON</span> customers.cust_id = orders.cust_id
<span class="hljs-keyword">GROUP</span> <span class="hljs-keyword">BY</span> customers.cust_id;
</code></pre>
<h4 id="&#x4F7F;&#x7528;&#x8054;&#x7ED3;&#x548C;&#x8054;&#x7ED3;&#x6761;&#x4EF6;">&#x4F7F;&#x7528;&#x8054;&#x7ED3;&#x548C;&#x8054;&#x7ED3;&#x6761;&#x4EF6;</h4>
<ul>
<li>&#x6CE8;&#x610F;&#x4F7F;&#x7528;&#x7684;&#x8054;&#x7ED3;&#x7C7B;&#x578B;</li>
<li>&#x4FDD;&#x8BC1;&#x4F7F;&#x7528;&#x6B63;&#x786E;&#x7684;&#x8054;&#x7ED3;&#x6761;&#x4EF6;</li>
<li>&#x5E94;&#x8BE5;&#x603B;&#x662F;&#x63D0;&#x4F9B;&#x8054;&#x7ED3;&#x6761;&#x4EF6;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x5F97;&#x51FA;&#x7B1B;&#x5361;&#x5C14;&#x79EF;</li>
<li>&#x5728;&#x4E00;&#x4E2A;&#x8054;&#x7ED3;&#x4E2D;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x591A;&#x4E2A;&#x8868;&#xFF0C;&#x751A;&#x81F3;&#x5BF9;&#x4E8E;&#x6BCF;&#x4E2A;&#x8054;&#x7ED3;&#x53EF;&#x4EE5;&#x91C7;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x8054;&#x7ED3;&#x7C7B;&#x578B;</li>
</ul>
<h3 id="&#x7EC4;&#x5408;&#x67E5;&#x8BE2;">&#x7EC4;&#x5408;&#x67E5;&#x8BE2;</h3>
<p>&#x6709;&#x4E24;&#x79CD;&#x57FA;&#x672C;&#x60C5;&#x51B5;&#xFF0C;&#x5176;&#x4E2D;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x7EC4;&#x5408;&#x67E5;&#x8BE2;&#xFF1A;</p>
<ul>
<li>&#x5728;&#x5355;&#x4E2A;&#x67E5;&#x8BE2;&#x4E2D;&#x4ECE;&#x4E0D;&#x540C;&#x7684;&#x8868;&#x8FD4;&#x56DE;&#x7C7B;&#x4F3C;&#x7ED3;&#x6784;&#x7684;&#x6570;&#x636E;</li>
<li>&#x5BF9;&#x5355;&#x4E2A;&#x8868;&#x6267;&#x884C;&#x591A;&#x4E2A;&#x67E5;&#x8BE2;&#xFF0C;&#x6309;&#x5355;&#x4E2A;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x6570;&#x636E;</li>
</ul>
<h4 id="&#x521B;&#x5EFA;&#x7EC4;&#x5408;&#x67E5;&#x8BE2;">&#x521B;&#x5EFA;&#x7EC4;&#x5408;&#x67E5;&#x8BE2;</h4>
<h5 id="union&#x64CD;&#x4F5C;&#x7B26;">UNION&#x64CD;&#x4F5C;&#x7B26;</h5>
<p>&#x4EE5;&#x4E0B;&#x4E24;&#x6761;SELECT&#x8BED;&#x53E5;&#x53EF;&#x4F7F;&#x7528;UNION&#x7EC4;&#x5408;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> vend_id, prod_id, prod_price
<span class="hljs-keyword">FROM</span> products
<span class="hljs-keyword">WHERE</span> prod_price &lt;= <span class="hljs-number">5</span>;
<span class="hljs-keyword">SELECT</span> vend_id, prod_id, prod_price
<span class="hljs-keyword">FROM</span> products
<span class="hljs-keyword">WHERE</span> vend_id <span class="hljs-keyword">IN</span> (<span class="hljs-number">1001</span>,<span class="hljs-number">1002</span>);
</code></pre>
<p>&#x7EC4;&#x5408;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> vend_id, prod_id, prod_price
<span class="hljs-keyword">FROM</span> products
<span class="hljs-keyword">WHERE</span> prod_price &lt;= <span class="hljs-number">5</span>;
UNION
<span class="hljs-keyword">SELECT</span> vend_id, prod_id, prod_price
<span class="hljs-keyword">FROM</span> products
<span class="hljs-keyword">WHERE</span> vend_id <span class="hljs-keyword">IN</span> (<span class="hljs-number">1001</span>,<span class="hljs-number">1002</span>);
</code></pre>
<p>&#x7ED9;&#x51FA;&#x4F7F;&#x7528;&#x591A;&#x6761;WHERE&#x5B50;&#x53E5;&#x800C;&#x4E0D;&#x662F;&#x4F7F;&#x7528;UNION&#x7684;&#x76F8;&#x540C;&#x67E5;&#x8BE2;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> vend_id, prod_id, prod_price
<span class="hljs-keyword">FROM</span> products
<span class="hljs-keyword">WHERE</span> prod_price &lt;= <span class="hljs-number">5</span>
    <span class="hljs-keyword">OR</span> vend_id <span class="hljs-keyword">IN</span> (<span class="hljs-number">1001</span>,<span class="hljs-number">1002</span>);
</code></pre>
<p>&#x8FD9;&#x91CC;&#x4F7F;&#x7528;UNION&#x53EF;&#x80FD;&#x6BD4;&#x4F7F;&#x7528;WHERE&#x5B50;&#x53E5;&#x66F4;&#x590D;&#x6742;&#xFF0C;&#x4F46;&#x662F;&#x5BF9;&#x4E8E;&#x66F4;&#x590D;&#x6742;&#x7684;&#x8FC7;&#x6EE4;&#x6761;&#x4EF6;&#xFF0C;&#x6216;&#x8005;&#x4ECE;&#x591A;&#x4E2A;&#x8868;&#x4E2D;&#x68C0;&#x7D22;&#x6570;&#x636E;&#x7684;&#x60C5;&#x5F62;&#xFF0C;&#x4F7F;&#x7528;UNION&#x53EF;&#x80FD;&#x4F1A;&#x4F7F;&#x5904;&#x7406;&#x66F4;&#x7B80;&#x5355;</p>
<h5 id="union&#x89C4;&#x5219;">UNION&#x89C4;&#x5219;</h5>
<ul>
<li>&#x5FC5;&#x987B;&#x7531;&#x4E24;&#x6761;&#x6216;&#x4EE5;&#x4E0A;SELECT&#x8BED;&#x53E5;&#x7EC4;&#x6210;</li>
<li>&#x6BCF;&#x4E2A;&#x67E5;&#x8BE2;&#x5FC5;&#x987B;&#x5305;&#x542B;&#x76F8;&#x540C;&#x7684;&#x5217;&#xFF0C;&#x8868;&#x8FBE;&#x5F0F;&#x6216;&#x805A;&#x96C6;&#x51FD;&#x6570;&#xFF08;&#x6B21;&#x5E8F;&#x53EF;&#x4E0D;&#x540C;&#xFF09;</li>
<li>&#x5217;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x517C;&#x5BB9;&#xFF1A;&#x7C7B;&#x578B;&#x4E0D;&#x5FC5;&#x5B8C;&#x5168;&#x76F8;&#x540C;&#xFF0C;&#x4F46;&#x5FC5;&#x987B;&#x662F;DBMS&#x53EF;&#x4EE5;&#x9690;&#x542B;&#x5730;&#x8F6C;&#x6362;&#x7684;&#x7C7B;&#x578B;</li>
</ul>
<h5 id="&#x5305;&#x542B;&#x6216;&#x53D6;&#x6D88;&#x91CD;&#x590D;&#x7684;&#x884C;">&#x5305;&#x542B;&#x6216;&#x53D6;&#x6D88;&#x91CD;&#x590D;&#x7684;&#x884C;</h5>
<p>UNION&#x4ECE;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x96C6;&#x4E2D;&#x81EA;&#x52A8;&#x53BB;&#x9664;&#x4E86;&#x91CD;&#x590D;&#x7684;&#x884C;</p>
<p>&#x5982;&#x679C;&#x60F3;&#x5339;&#x914D;&#x6240;&#x6709;&#x884C;&#xFF0C;&#x53EF;&#x4F7F;&#x7528;<code>UNION ALL</code>&#x800C;&#x4E0D;&#x662F;<code>UNION</code></p>
<h5 id="&#x5BF9;&#x7EC4;&#x5408;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x6392;&#x5E8F;">&#x5BF9;&#x7EC4;&#x5408;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x6392;&#x5E8F;</h5>
<p>SELECT&#x8BED;&#x53E5;&#x7684;&#x8F93;&#x51FA;&#x7528;ORDER BY&#x5B50;&#x53E5;&#x6392;&#x5E8F;&#x3002;</p>
<p>&#x5728;&#x7528;UNION&#x7EC4;&#x5408;&#x67E5;&#x8BE2;&#x65F6;&#xFF0C;&#x53EA;&#x80FD;&#x7528;&#x4E00;&#x6761;ORDER BY&#x5B50;&#x53E5;&#xFF0C;&#x5B83;&#x5FC5;&#x987B;&#x51FA;&#x73B0;&#x5728;&#x6700;&#x540E;&#x4E00;&#x6761;SELECT&#x8BED;&#x53E5;&#x4E4B;&#x540E;</p>
<h3 id="&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;">&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;</h3>
<p><strong>&#x5E76;&#x975E;&#x6240;&#x6709;&#x5F15;&#x64CE;&#x90FD;&#x652F;&#x6301;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;</strong></p>
<p>MyISAM&#x652F;&#x6301;&#xFF0C;InnoDB&#x4E0D;&#x652F;&#x6301;</p>
<h4 id="&#x4F7F;&#x7528;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;">&#x4F7F;&#x7528;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;</h4>
<blockquote>
<p>&#x4E3A;&#x4E86;&#x8FDB;&#x884C;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#xFF0C;&#x5FC5;&#x987B;&#x7D22;&#x5F15;&#x88AB;&#x641C;&#x7D22;&#x7684;&#x5217;&#xFF0C;&#x800C;&#x4E14;&#x8981;&#x968F;&#x7740;&#x6570;&#x636E;&#x7684;&#x6539;&#x53D8;&#x4E0D;&#x65AD;&#x5730;&#x91CD;&#x65B0;&#x7D22;&#x5F15;</p>
</blockquote>
<p>&#x5728;&#x5BF9;&#x8868;&#x5217;&#x8FDB;&#x884C;&#x9002;&#x5F53;&#x8BBE;&#x8BA1;&#x540E;&#xFF0C;MySQL&#x4F1A;&#x81EA;&#x52A8;&#x8FDB;&#x884C;&#x6240;&#x6709;&#x7684;&#x7D22;&#x5F15;&#x548C;&#x91CD;&#x65B0;&#x7D22;&#x5F15;</p>
<h4 id="&#x542F;&#x7528;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x652F;&#x6301;">&#x542F;&#x7528;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x652F;&#x6301;</h4>
<p>&#x4E00;&#x822C;&#x5728;&#x521B;&#x5EFA;&#x8868;&#x65F6;&#x542F;&#x7528;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x3002;<code>CREATE TABLE</code>&#x8BED;&#x53E5;&#x63A5;&#x6536;FULLTEXT&#x5B50;&#x53E5;&#xFF0C;&#x5B83;&#x7ED9;&#x51FA;&#x88AB;&#x7D22;&#x5F15;&#x5217;&#x7684;&#x4E00;&#x4E2A;&#x9017;&#x53F7;&#x5206;&#x9694;&#x7684;&#x5217;&#x8868;&#x3002;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> productnotes
(
  note_id    <span class="hljs-built_in">int</span>           <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> AUTO_INCREMENT,
  prod_id    <span class="hljs-built_in">char</span>(<span class="hljs-number">10</span>)      <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
  note_date datetime       <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
  note_text  <span class="hljs-built_in">text</span>          <span class="hljs-literal">NULL</span> ,
  PRIMARY <span class="hljs-keyword">KEY</span>(note_id),
  FULLTEXT(note_text)
) <span class="hljs-keyword">ENGINE</span>=MyISAM;
</code></pre>
<p>&#x6709;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>note_text</code>&#x7684;&#x5217;&#xFF0C;&#x4E3A;&#x4E86;&#x8FDB;&#x884C;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#xFF0C;MySQL&#x6839;&#x636E;&#x5B50;&#x53E5;FULLTEXT(note_text)&#x7684;&#x6307;&#x793A;&#x5BF9;&#x5B83;&#x8FDB;&#x884C;&#x7D22;&#x5F15;&#x3002;</p>
<h4 id="&#x8FDB;&#x884C;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;">&#x8FDB;&#x884C;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;</h4>
<p>&#x4F7F;&#x7528;&#x4E24;&#x4E2A;&#x51FD;&#x6570;Match()&#x548C;Against()&#x6267;&#x884C;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#xFF0C;&#x5176;&#x4E2D;Match()&#x6307;&#x5B9A;&#x88AB;&#x641C;&#x7D22;&#x7684;&#x5217;&#xFF0C;Against()&#x6307;&#x5B9A;&#x8981;&#x4F7F;&#x7528;&#x7684;&#x641C;&#x7D22;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> note_text
<span class="hljs-keyword">FROM</span> productnotes
<span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">Match</span>(note_text) Against(<span class="hljs-string">&apos;rabbit&apos;</span>);
</code></pre>
<p>&#x6B64;select&#x8BED;&#x53E5;&#x68C0;&#x7D22;&#x5355;&#x4E2A;&#x5217;note_text&#xFF0C;&#x7531;&#x4E8E;WHERE&#x5B50;&#x53E5;&#xFF0C;&#x4E00;&#x4E2A;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x88AB;&#x6267;&#x884C;&#x3002;Match(note_text)&#x6307;&#x793A;MySQL&#x9488;&#x5BF9;&#x7684;&#x5217;&#x8FDB;&#x884C;&#x641C;&#x7D22;&#xFF0C;Against(&apos;rabbit&apos;)&#x6307;&#x5B9A;&#x8BCD;rabbit&#x4F5C;&#x4E3A;&#x641C;&#x7D22;&#x6587;&#x672C;&#x3002;</p>
<p>Match()&#x8BF4;&#x660E;&#xFF1A;&#x4F20;&#x9012;&#x7ED9;Match()&#x7684;&#x503C;&#x5FC5;&#x987B;&#x4E0E;FULLTEXT()&#x5B9A;&#x4E49;&#x4E2D;&#x7684;&#x76F8;&#x540C;&#x3002;&#x5982;&#x679C;&#x6307;&#x5B9A;&#x591A;&#x4E2A;&#x5217;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x5217;&#x51FA;&#x5B83;&#x4EEC;&#xFF08;&#x800C;&#x4E14;&#x6B21;&#x5E8F;&#x6B63;&#x786E;&#xFF09;&#x3002;</p>
<p>&#x641C;&#x7D22;&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#xFF1A;&#x9664;&#x975E;&#x4F7F;&#x7528;BINARY&#x65B9;&#x5F0F;&#x3002;</p>
<p>&#x4E8B;&#x5B9E;&#x4E0A;&#xFF0C;&#x521A;&#x624D;&#x7684;&#x641C;&#x7D22;&#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x7684;&#x7528;like&#x5B50;&#x53E5;&#x66FF;&#x6362;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> note_text
<span class="hljs-keyword">FROM</span> productnotes
<span class="hljs-keyword">WHERE</span> note_text <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&apos;%rabbit%&apos;</span>;
</code></pre>
<p>LIKE&#x4EE5;&#x4E0D;&#x7279;&#x522B;&#x6709;&#x7528;&#x7684;&#x987A;&#x5E8F;&#x8FD4;&#x56DE;&#x6570;&#x636E;&#x3002;</p>
<p>&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x8FD4;&#x56DE;&#x4EE5;&#x6587;&#x672C;&#x5339;&#x914D;&#x7684;&#x826F;&#x597D;&#x7A0B;&#x5EA6;&#x6392;&#x5E8F;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<h4 id="&#x4F7F;&#x7528;&#x67E5;&#x8BE2;&#x6269;&#x5C55;">&#x4F7F;&#x7528;&#x67E5;&#x8BE2;&#x6269;&#x5C55;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> note_text
<span class="hljs-keyword">FROM</span> productnotes
<span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">Match</span>(note_text) Against(<span class="hljs-string">&apos;anvils&apos;</span> <span class="hljs-keyword">WITH</span> EXPANSION);
</code></pre>
<p>&#x884C;&#x8D8A;&#x591A;&#x4F7F;&#x7528;&#x6269;&#x5C55;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x7684;&#x7ED3;&#x679C;&#x8D8A;&#x597D;</p>
<h4 id="&#x5E03;&#x5C14;&#x6587;&#x672C;&#x641C;&#x7D22;">&#x5E03;&#x5C14;&#x6587;&#x672C;&#x641C;&#x7D22;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> note_text
<span class="hljs-keyword">FROM</span> productnotes
<span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">Match</span>(note_text) Against(<span class="hljs-string">&apos;heavy&apos;</span> <span class="hljs-keyword">IN</span> <span class="hljs-built_in">BOOLEAN</span> <span class="hljs-keyword">MODE</span>);
</code></pre>
<h4 id="&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x7684;&#x4F7F;&#x7528;&#x8BF4;&#x660E;">&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x7684;&#x4F7F;&#x7528;&#x8BF4;&#x660E;</h4>
<ul>
<li>&#x5728;&#x7D22;&#x5F15;&#x5168;&#x6587;&#x672C;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x77ED;&#x8BCD;&#x88AB;&#x5FFD;&#x7565;&#x4E14;&#x4ECE;&#x7D22;&#x5F15;&#x4E2D;&#x6392;&#x9664;</li>
<li>MySQL&#x5E26;&#x6709;&#x4E00;&#x4E2A;&#x5185;&#x5EFA;&#x7684;&#x975E;&#x7528;&#x8BCD;&#xFF08;stopword&#xFF09;&#x5217;&#x8868;&#xFF0C;&#x8FD9;&#x4E9B;&#x8BCD;&#x5728;&#x7D22;&#x5F15;&#x5168;&#x6587;&#x672C;&#x6570;&#x636E;&#x65F6;&#x603B;&#x662F;&#x88AB;&#x5FFD;&#x7565;</li>
<li>&#x8BB8;&#x591A;&#x6B21;&#x51FA;&#x73B0;&#x7684;&#x9891;&#x7387;&#x5F88;&#x9AD8;&#xFF0C;&#x641C;&#x7D22;&#x5B83;&#x4EEC;&#x6CA1;&#x6709;&#x7528;&#x5904;&#x3002;MySQL&#x5236;&#x5B9A;&#x4E86;&#x4E00;&#x6761;50%&#x89C4;&#x5219;</li>
<li>&#x5982;&#x679C;&#x8868;&#x4E2D;&#x7684;&#x884C;&#x6570;&#x5C11;&#x4E8E;3&#x884C;&#xFF0C;&#x5219;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x4E0D;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;</li>
<li>&#x5FFD;&#x7565;&#x8BCD;&#x4E2D;&#x7684;&#x5355;&#x5F15;&#x53F7;</li>
<li>&#x4E0D;&#x5177;&#x6709;&#x8BCD;&#x5206;&#x9694;&#x7B26;&#x7684;&#x8BED;&#x8A00;&#x4E0D;&#x80FD;&#x6070;&#x5F53;&#x5730;&#x8FD4;&#x56DE;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#x7ED3;&#x679C;</li>
<li>&#x4EC5;&#x5728;MyISAM&#x6570;&#x636E;&#x5E93;&#x7D22;&#x5F15;&#x4E2D;&#x652F;&#x6301;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;</li>
</ul>
<h3 id="&#x63D2;&#x5165;&#x6570;&#x636E;">&#x63D2;&#x5165;&#x6570;&#x636E;</h3>
<h4 id="&#x63D2;&#x5165;&#x5B8C;&#x6574;&#x7684;&#x884C;">&#x63D2;&#x5165;&#x5B8C;&#x6574;&#x7684;&#x884C;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> Customers <span class="hljs-keyword">VALUES</span>(<span class="hljs-literal">NULL</span>, <span class="hljs-string">&apos;Pep E. LaPew&apos;</span>, <span class="hljs-string">&apos;100 Main Street&apos;</span>, <span class="hljs-string">&apos;Los Angeles&apos;</span>, <span class="hljs-string">&apos;CA&apos;</span>, <span class="hljs-string">&apos;90046&apos;</span>, <span class="hljs-string">&apos;USA&apos;</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-literal">NULL</span>);
</code></pre>
<p>&#x66F4;&#x5B89;&#x5168;&#x7684;&#x65B9;&#x5F0F;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> Customers(cust_name, cust_contact, cust_email, cust_address, cust_city, cust_state, cust_zip, cust_conutry) 
<span class="hljs-keyword">VALUES</span>(<span class="hljs-string">&apos;Pep E. LaPew&apos;</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-string">&apos;100 Main Street&apos;</span>, <span class="hljs-string">&apos;Los Angeles&apos;</span>, <span class="hljs-string">&apos;CA&apos;</span>, <span class="hljs-string">&apos;90046&apos;</span>, <span class="hljs-string">&apos;USA&apos;</span>);
</code></pre>
<p>&#x5FC5;&#x987B;&#x7ED9;&#x51FA;VALUES&#x7684;&#x6B63;&#x786E;&#x6570;&#x76EE;&#x3002;&#x5982;&#x679C;&#x4E0D;&#x63D0;&#x4F9B;&#x5217;&#x540D;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x7ED9;&#x6BCF;&#x4E2A;&#x5217;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x503C;&#x3002;&#x5982;&#x679C;&#x63D0;&#x4F9B;&#x5217;&#x540D;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x5BF9;&#x6BCF;&#x4E2A;&#x5217;&#x51FA;&#x7684;&#x5217;&#x7ED9;&#x51FA;&#x4E00;&#x4E2A;&#x503C;&#x3002;</p>
<p><strong>&#x7701;&#x7565;&#x5217;</strong></p>
<ul>
<li>&#x8BE5;&#x5217;&#x5B9A;&#x4E49;&#x4E3A;&#x5141;&#x8BB8;NULL&#x503C;</li>
<li>&#x5728;&#x8868;&#x5B9A;&#x4E49;&#x4E2D;&#x7ED9;&#x51FA;&#x9ED8;&#x8BA4;&#x503C;</li>
</ul>
<h4 id="&#x63D2;&#x5165;&#x591A;&#x884C;">&#x63D2;&#x5165;&#x591A;&#x884C;</h4>
<p>&#x591A;&#x6761;INSERT&#x8BED;&#x53E5;</p>
<p>&#x6216;&#x8005;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> customers(&#x2026;&#x2026;) <span class="hljs-keyword">VALUES</span>(&#x2026;&#x2026;),(&#x2026;&#x2026;);
</code></pre>
<h4 id="&#x63D2;&#x5165;&#x67D0;&#x4E9B;&#x67E5;&#x8BE2;&#x7684;&#x7ED3;&#x679C;">&#x63D2;&#x5165;&#x67D0;&#x4E9B;&#x67E5;&#x8BE2;&#x7684;&#x7ED3;&#x679C;</h4>
<p><code>INSERT SELECT</code></p>
<h3 id="&#x66F4;&#x65B0;&#x548C;&#x5220;&#x9664;&#x6570;&#x636E;">&#x66F4;&#x65B0;&#x548C;&#x5220;&#x9664;&#x6570;&#x636E;</h3>
<h4 id="&#x66F4;&#x65B0;&#x6570;&#x636E;">&#x66F4;&#x65B0;&#x6570;&#x636E;</h4>
<ul>
<li>&#x66F4;&#x65B0;&#x7279;&#x5B9A;&#x884C;</li>
<li>&#x66F4;&#x65B0;&#x6240;&#x6709;&#x884C;</li>
</ul>
<p><strong>&#x4E0D;&#x8981;&#x7701;&#x7565;WHERE&#x5B50;&#x53E5;</strong></p>
<p>UPDATE&#x8BED;&#x53E5;&#x4E09;&#x90E8;&#x5206;</p>
<ol>
<li>&#x8981;&#x66F4;&#x65B0;&#x7684;&#x8868;</li>
<li>&#x5217;&#x540D;&#x548C;&#x5B83;&#x4EEC;&#x7684;&#x65B0;&#x503C;</li>
<li>&#x786E;&#x5B9A;&#x8981;&#x66F4;&#x65B0;&#x884C;&#x7684;&#x8FC7;&#x6EE4;&#x6761;&#x4EF6;</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">UPDATE</span> customers <span class="hljs-keyword">SET</span> cust_email = <span class="hljs-string">&apos;elmer@fudd.com&apos;</span> <span class="hljs-keyword">WHERE</span> cust_id = <span class="hljs-number">10005</span>;
</code></pre>
<p>&#x5982;&#x679C;&#x7528;UPDATE&#x66F4;&#x65B0;&#x591A;&#x884C;&#xFF0C;&#x66F4;&#x65B0;&#x65F6;&#x53EF;&#x80FD;&#x4F1A;&#x51FA;&#x73B0;&#x9519;&#x8BEF;&#xFF0C;&#x90A3;&#x4E48;&#x5219;&#x6574;&#x4E2A;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;&#x90FD;&#x4F1A;&#x88AB;&#x53D6;&#x6D88;&#x3002;</p>
<p>&#x5982;&#x679C;&#x60F3;&#x5373;&#x4F7F;&#x53D1;&#x751F;&#x9519;&#x8BEF;&#x4E5F;&#x8981;&#x7EE7;&#x7EED;&#x66F4;&#x65B0;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>IGNORE</code>&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x793A;&#x4F8B;<code>UPDATE IGNORE customers...</code></p>
<h4 id="&#x5220;&#x9664;&#x6570;&#x636E;">&#x5220;&#x9664;&#x6570;&#x636E;</h4>
<ul>
<li>&#x5220;&#x9664;&#x7279;&#x5B9A;&#x884C;</li>
<li>&#x5220;&#x9664;&#x6240;&#x6709;&#x884C;</li>
</ul>
<p><strong>&#x4E0D;&#x8981;&#x7701;&#x7565;WHERE&#x5B50;&#x53E5;</strong></p>
<pre><code class="lang-sql"><span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> customers <span class="hljs-keyword">WHERE</span> cust_id = <span class="hljs-number">10006</span>;
</code></pre>
<p><strong>&#x5220;&#x9664;&#x6240;&#x6709;&#x884C;</strong>&#xFF1A;&#x4F7F;&#x7528;<code>TRUNCATE TABLE</code> truncate&#x5B9E;&#x9645;&#x662F;&#x5220;&#x9664;&#x539F;&#x6765;&#x7684;&#x8868;&#x5E76;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8868;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x9010;&#x884C;&#x5220;&#x9664;&#x6570;&#x636E;</p>
<h3 id="&#x521B;&#x5EFA;&#x548C;&#x64CD;&#x7EB5;&#x8868;">&#x521B;&#x5EFA;&#x548C;&#x64CD;&#x7EB5;&#x8868;</h3>
<h4 id="&#x521B;&#x5EFA;&#x8868;">&#x521B;&#x5EFA;&#x8868;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> customers(
    cust_id             <span class="hljs-built_in">int</span>            <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span> AUTO_INCREMENT,
    cust_name         <span class="hljs-built_in">char</span>(<span class="hljs-number">50</span>)    <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    cust_address    <span class="hljs-built_in">char</span>(<span class="hljs-number">50</span>)    <span class="hljs-literal">NULL</span>,
    cust_city        <span class="hljs-built_in">char</span>(<span class="hljs-number">50</span>)    <span class="hljs-literal">NULL</span>,
    cust_state        <span class="hljs-built_in">char</span>(<span class="hljs-number">5</span>)        <span class="hljs-literal">NULL</span>,
    cust_zip        <span class="hljs-built_in">char</span>(<span class="hljs-number">10</span>)    <span class="hljs-literal">NULL</span>,
    cust_country    <span class="hljs-built_in">char</span>(<span class="hljs-number">50</span>)    <span class="hljs-literal">NULL</span>,
    cust_contact    <span class="hljs-built_in">char</span>(<span class="hljs-number">50</span>)    <span class="hljs-literal">NULL</span>,
    cust_email        <span class="hljs-built_in">char</span>(<span class="hljs-number">255</span>)    <span class="hljs-literal">NULL</span>,
    PRIMARY <span class="hljs-keyword">KEY</span>    (cust_id)
)<span class="hljs-keyword">ENGINE</span>=<span class="hljs-keyword">InnoDB</span>;
</code></pre>
<p>&#x786E;&#x5B9A;AUTO_INCREMENT&#x7684;&#x503C;</p>
<p>&#x4F7F;&#x7528; SELECT last_insert_id()&#x51FD;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x6700;&#x540E;&#x4E00;&#x4E2A;AUTO_INCREMENT&#x503C;</p>
<h4 id="&#x5F15;&#x64CE;&#x7C7B;&#x578B;">&#x5F15;&#x64CE;&#x7C7B;&#x578B;</h4>
<ul>
<li>InnoDB&#xFF1A;&#x53EF;&#x9760;&#x7684;&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x5F15;&#x64CE;&#xFF0C;&#x4E0D;&#x652F;&#x6301;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;</li>
<li>MEMORY&#xFF1A;&#x529F;&#x80FD;&#x7B49;&#x540C;&#x4E8E;MyISAM&#xFF0C;&#x4F46;&#x7528;&#x4E8E;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x5728;&#x5185;&#x5B58;&#xFF08;&#x4E0D;&#x662F;&#x78C1;&#x76D8;&#xFF09;&#x4E2D;&#xFF0C;&#x901F;&#x5EA6;&#x5F88;&#x5FEB;&#xFF08;&#x7279;&#x522B;&#x9002;&#x5408;&#x4E8E;&#x4E34;&#x65F6;&#x8868;&#xFF09;</li>
<li>MyISAM&#xFF1A;&#x6027;&#x80FD;&#x6781;&#x9AD8;&#x7684;&#x5F15;&#x64CE;&#xFF0C;&#x652F;&#x6301;&#x5168;&#x6587;&#x672C;&#x641C;&#x7D22;&#xFF0C;&#x4F46;&#x4E0D;&#x652F;&#x6301;&#x4E8B;&#x52A1;&#x5904;&#x7406;</li>
</ul>
<p>&#x5916;&#x952E;&#x4E0D;&#x80FD;&#x8DE8;&#x5F15;&#x64CE;</p>
<h4 id="&#x66F4;&#x65B0;&#x8868;">&#x66F4;&#x65B0;&#x8868;</h4>
<p><code>ALTER TABLE</code></p>
<pre><code class="lang-sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> venders <span class="hljs-keyword">ADD</span> vend_phone <span class="hljs-built_in">CHAR</span>(<span class="hljs-number">20</span>);    <span class="hljs-comment">-- &#x6DFB;&#x52A0;&#x5217;</span>
<span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> venders <span class="hljs-keyword">DROP</span> <span class="hljs-keyword">COLUMN</span> vend_phone;        <span class="hljs-comment">-- &#x5220;&#x9664;&#x5217;</span>
</code></pre>
<p>&#x5E38;&#x89C1;&#x7528;&#x9014;&#xFF1A;&#x5B9A;&#x4E49;&#x5916;&#x952E;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> orderitems
<span class="hljs-keyword">ADD</span> <span class="hljs-keyword">CONSTRAINT</span> fk_orderitems_orders
FOREIGN <span class="hljs-keyword">KEY</span> (order_num) <span class="hljs-keyword">REFERENCES</span> orders (order_num);
</code></pre>
<h4 id="&#x5220;&#x9664;&#x8868;">&#x5220;&#x9664;&#x8868;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">TABLE</span> customers2;
</code></pre>
<h4 id="&#x91CD;&#x547D;&#x540D;&#x8868;">&#x91CD;&#x547D;&#x540D;&#x8868;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">RENAME</span> <span class="hljs-keyword">TABLE</span> customers2 <span class="hljs-keyword">TO</span> customers;
</code></pre>
<h3 id="&#x4F7F;&#x7528;&#x89C6;&#x56FE;">&#x4F7F;&#x7528;&#x89C6;&#x56FE;</h3>
<h3 id="&#x4F7F;&#x7528;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;">&#x4F7F;&#x7528;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;</h3>
<h3 id="&#x4F7F;&#x7528;&#x6E38;&#x6807;">&#x4F7F;&#x7528;&#x6E38;&#x6807;</h3>
<h3 id="&#x4F7F;&#x7528;&#x89E6;&#x53D1;&#x5668;">&#x4F7F;&#x7528;&#x89E6;&#x53D1;&#x5668;</h3>
<h3 id="star&#x7BA1;&#x7406;&#x4E8B;&#x52A1;&#x5904;&#x7406;">:star:&#x7BA1;&#x7406;&#x4E8B;&#x52A1;&#x5904;&#x7406;</h3>
<h4 id="&#x4E8B;&#x52A1;&#x5904;&#x7406;">&#x4E8B;&#x52A1;&#x5904;&#x7406;</h4>
<p><strong>&#x5E76;&#x975E;&#x6240;&#x6709;&#x5F15;&#x64CE;&#x90FD;&#x652F;&#x6301;&#x4E8B;&#x52A1;&#x5904;&#x7406;</strong>&#xFF1A;InnoDB&#x652F;&#x6301;&#xFF0C;MyISAM&#x4E0D;&#x652F;&#x6301;</p>
<blockquote>
<p>&#x7EF4;&#x62A4;&#x6570;&#x636E;&#x5E93;&#x7684;&#x5B8C;&#x6574;&#x6027;&#xFF0C;&#x4FDD;&#x8BC1;&#x6210;&#x6279;&#x7684;MySQL&#x64CD;&#x4F5C;&#x8981;&#x4E48;&#x5B8C;&#x5168;&#x6267;&#x884C;&#xFF0C;&#x8981;&#x4E48;&#x5B8C;&#x5168;&#x4E0D;&#x6267;&#x884C;</p>
</blockquote>
<p>&#x51E0;&#x4E2A;&#x672F;&#x8BED;&#xFF1A;</p>
<ul>
<li>&#x4E8B;&#x52A1;&#xFF08;transaction&#xFF09;&#xFF1A;&#x6307;&#x4E00;&#x7EC4;SQL&#x8BED;&#x53E5;</li>
<li>&#x56DE;&#x9000;&#xFF08;rollback&#xFF09;&#xFF1A;&#x6307;&#x64A4;&#x9500;&#x6307;&#x5B9A;SQL&#x8BED;&#x53E5;&#x7684;&#x8FC7;&#x7A0B;</li>
<li>&#x63D0;&#x4EA4;&#xFF08;commit&#xFF09;&#xFF1A;&#x6307;&#x5C06;&#x672A;&#x5B58;&#x50A8;&#x7684;SQL&#x8BED;&#x53E5;&#x5199;&#x5165;&#x6570;&#x636E;&#x5E93;&#x8868;</li>
<li>&#x4FDD;&#x7559;&#x70B9;&#xFF08;savepoint&#xFF09;&#xFF1A;&#x6307;&#x4E8B;&#x52A1;&#x53D1;&#x5E03;&#x4E2D;&#x8BBE;&#x7F6E;&#x7684;&#x4E34;&#x65F6;&#x5360;&#x4F4D;&#x7B26;&#xFF08;placeholder&#xFF09;&#xFF0C;&#x53EF;&#x4EE5;&#x5BF9;&#x5B83;&#x53D1;&#x5E03;&#x56DE;&#x9000;&#xFF08;&#x4E0E;&#x56DE;&#x9000;&#x6574;&#x4E2A;&#x4E8B;&#x52A1;&#x4E0D;&#x540C;&#xFF09;</li>
</ul>
<h4 id="&#x63A7;&#x5236;&#x4E8B;&#x52A1;&#x5904;&#x7406;">&#x63A7;&#x5236;&#x4E8B;&#x52A1;&#x5904;&#x7406;</h4>
<h5 id="&#x4F7F;&#x7528;rollback">&#x4F7F;&#x7528;ROLLBACK</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> ordertotals;
<span class="hljs-keyword">START</span> <span class="hljs-keyword">TRANSACTION</span>    <span class="hljs-comment">-- &#x6807;&#x8BC6;&#x4E8B;&#x52A1;&#x5F00;&#x59CB;</span>
<span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> ordertotals;
<span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> ordertotals;
<span class="hljs-keyword">ROLLBACK</span>;            <span class="hljs-comment">-- &#x56DE;&#x6EDA;</span>
<span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> ordertotals;
</code></pre>
<p>&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x7528;&#x6765;&#x7BA1;&#x7406;<code>INSERT&#x3001;UPDATE&#x3001;DELETE</code>&#x8BED;&#x53E5;&#x3002;&#x4E0D;&#x80FD;&#x56DE;&#x9000;<code>SELECT</code>&#x8BED;&#x53E5;&#xFF08;&#x6CA1;&#x610F;&#x4E49;&#xFF09;&#xFF0C;&#x4E0D;&#x80FD;&#x56DE;&#x9000;<code>CREATE&#x3001;DROP</code>&#x64CD;&#x4F5C;&#xFF0C;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x4E2D;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E24;&#x6761;&#x8BED;&#x53E5;&#xFF0C;&#x4F46;&#x662F;&#x6267;&#x884C;&#x56DE;&#x9000;&#x5E76;&#x4E0D;&#x4F1A;&#x88AB;&#x64A4;&#x9500;&#x3002;</p>
<h5 id="&#x4F7F;&#x7528;commit">&#x4F7F;&#x7528;COMMIT</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">START</span> <span class="hljs-keyword">TRANSACTION</span>    <span class="hljs-comment">-- &#x6807;&#x8BC6;&#x4E8B;&#x52A1;&#x5F00;&#x59CB;</span>
<span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> ordertotals <span class="hljs-keyword">WHERE</span> order_num = <span class="hljs-number">20010</span>;
<span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> orders <span class="hljs-keyword">WHERE</span> order_num = <span class="hljs-number">20010</span>;
<span class="hljs-keyword">COMMIT</span>;            <span class="hljs-comment">-- &#x63D0;&#x4EA4;</span>
</code></pre>
<p>&#x5F53;COMMIT&#x6216;ROLLBACK&#x8BED;&#x53E5;&#x6267;&#x884C;&#x540E;&#xFF0C;&#x4E8B;&#x52A1;&#x4F1A;&#x81EA;&#x52A8;&#x5173;&#x95ED;&#xFF08;&#x5C06;&#x6765;&#x7684;&#x66F4;&#x6539;&#x4F1A;&#x9690;&#x542B;&#x63D0;&#x4EA4;&#xFF09;</p>
<h5 id="&#x4F7F;&#x7528;&#x4FDD;&#x7559;&#x70B9;">&#x4F7F;&#x7528;&#x4FDD;&#x7559;&#x70B9;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">SAVEPOINT</span> delete1;
<span class="hljs-keyword">ROLLBACK</span> <span class="hljs-keyword">TO</span> delete1;
</code></pre>
<p>&#x4FDD;&#x7559;&#x70B9;&#x8D8A;&#x591A;&#x8D8A;&#x597D;</p>
<p>&#x4FDD;&#x7559;&#x70B9;&#x5728;&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x5B8C;&#x6210;&#x540E;&#xFF08;&#x6267;&#x884C;&#x4E00;&#x6761;&#xFF09;&#x81EA;&#x52A8;&#x91CA;&#x653E;&#xFF0C;MySQL 5&#x4EE5;&#x6765;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;RELEASE SAVEPOINT&#x660E;&#x786E;&#x5730;&#x91CA;&#x653E;&#x4FDD;&#x7559;&#x70B9;&#x3002;</p>
<h4 id="&#x66F4;&#x6539;&#x9ED8;&#x8BA4;&#x7684;&#x63D0;&#x4EA4;&#x884C;&#x4E3A;">&#x66F4;&#x6539;&#x9ED8;&#x8BA4;&#x7684;&#x63D0;&#x4EA4;&#x884C;&#x4E3A;</h4>
<p>&#x9ED8;&#x8BA4;MySQL&#x884C;&#x4E3A;&#x662F;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;&#x6240;&#x6709;&#x66F4;&#x6539;&#x3002;&#x4E3A;&#x6307;&#x793A;MySQL&#x4E0D;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;&#x66F4;&#x6539;&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x8BED;&#x53E5;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SET</span> autocommit=<span class="hljs-number">0</span>;
</code></pre>
<p>autocommit&#x6807;&#x5FD7;&#x51B3;&#x5B9A;&#x662F;&#x5426;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;&#x66F4;&#x6539;&#xFF0C;&#x4E0D;&#x7BA1;&#x6709;&#x6CA1;&#x6709;commit&#x8BED;&#x53E5;&#x3002;&#x8BBE;&#x7F6E;autocommit&#x4E3A;0&#xFF08;&#x5047;&#xFF09;&#x6307;&#x793A;MySQL&#x4E0D;&#x81EA;&#x52A8;&#x63D0;&#x4EA4;&#x66F4;&#x6539;&#xFF08;&#x76F4;&#x5230;autocommit&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A;&#x771F;&#x4E3A;&#x6B62;&#xFF09;</p>
<p><strong>autocommit&#x6807;&#x5FD7;&#x662F;&#x9488;&#x5BF9;&#x6BCF;&#x4E2A;&#x8FDE;&#x63A5;&#x800C;&#x4E0D;&#x662F;&#x670D;&#x52A1;&#x5668;&#x7684;</strong></p>
<h3 id="&#x5168;&#x7403;&#x5316;&#x548C;&#x672C;&#x5730;&#x5316;">&#x5168;&#x7403;&#x5316;&#x548C;&#x672C;&#x5730;&#x5316;</h3>
<h4 id="&#x4F7F;&#x7528;&#x5B57;&#x7B26;&#x96C6;&#x548C;&#x6821;&#x5BF9;&#x987A;&#x5E8F;">&#x4F7F;&#x7528;&#x5B57;&#x7B26;&#x96C6;&#x548C;&#x6821;&#x5BF9;&#x987A;&#x5E8F;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-built_in">character</span> <span class="hljs-keyword">set</span>;        <span class="hljs-comment">-- &#x663E;&#x793A;&#x6240;&#x6709;&#x53EF;&#x7528;&#x7684;&#x5B57;&#x7B26;&#x96C6;&#x4EE5;&#x53CA;&#x6BCF;&#x4E2A;&#x5B57;&#x7B26;&#x96C6;&#x7684;&#x63CF;&#x8FF0;&#x548C;&#x9ED8;&#x8BA4;&#x6821;&#x5BF9;</span>
<span class="hljs-keyword">show</span> <span class="hljs-keyword">collation</span>;            <span class="hljs-comment">-- &#x663E;&#x793A;&#x6240;&#x6709;&#x53EF;&#x7528;&#x7684;&#x6821;&#x5BF9;&#xFF0C;&#x4EE5;&#x53CA;&#x5B83;&#x4EEC;&#x9002;&#x7528;&#x7684;&#x5B57;&#x7B26;&#x96C6;</span>
</code></pre>
<h3 id="&#x5B89;&#x5168;&#x63A7;&#x5236;">&#x5B89;&#x5168;&#x63A7;&#x5236;</h3>
<h4 id="&#x7BA1;&#x7406;&#x7528;&#x6237;">&#x7BA1;&#x7406;&#x7528;&#x6237;</h4>
<pre><code class="lang-sql"><span class="hljs-keyword">use</span> mysql;
<span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">user</span> <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">user</span>;
</code></pre>
<h5 id="&#x521B;&#x5EFA;&#x7528;&#x6237;&#x8D26;&#x53F7;">&#x521B;&#x5EFA;&#x7528;&#x6237;&#x8D26;&#x53F7;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-keyword">USER</span> ben <span class="hljs-keyword">IDENTIFIED</span> <span class="hljs-keyword">by</span> <span class="hljs-string">&apos;p@$$w0rd&apos;</span>;
</code></pre>
<p>&#x91CD;&#x547D;&#x540D;&#x7528;&#x6237;&#x8D26;&#x53F7;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">RENAME</span> <span class="hljs-keyword">USER</span> ben <span class="hljs-keyword">TO</span> bforta;
</code></pre>
<h5 id="&#x5220;&#x9664;&#x7528;&#x6237;&#x8D26;&#x6237;">&#x5220;&#x9664;&#x7528;&#x6237;&#x8D26;&#x6237;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">USER</span> bforta;
</code></pre>
<h5 id="&#x8BBE;&#x7F6E;&#x8BBF;&#x95EE;&#x6743;&#x9650;">&#x8BBE;&#x7F6E;&#x8BBF;&#x95EE;&#x6743;&#x9650;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-keyword">grants</span> <span class="hljs-keyword">for</span> bforta;        <span class="hljs-comment">-- &#x67E5;&#x770B;&#x8D4B;&#x4E88;&#x7528;&#x6237;&#x7684;&#x6743;&#x9650;</span>
<span class="hljs-comment">-- &#x663E;&#x793A;&#x6709;&#x4E00;&#x4E2A;&#x6743;&#x9650;USAGE ON *.* USAGE&#x8868;&#x793A;&#x6839;&#x672C;&#x6CA1;&#x6709;&#x6743;&#x9650;</span>
</code></pre>
<p>&#x8BBE;&#x7F6E;&#x6743;&#x9650;&#xFF0C;&#x4F7F;&#x7528;GRANT&#x8BED;&#x53E5;&#x3002;&#x81F3;&#x5C11;&#x8981;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x4FE1;&#x606F;&#xFF1A;</p>
<ul>
<li>&#x8981;&#x6388;&#x4E88;&#x7684;&#x6743;&#x9650;</li>
<li>&#x88AB;&#x6388;&#x4E88;&#x8BBF;&#x95EE;&#x6743;&#x9650;&#x7684;&#x6570;&#x636E;&#x5E93;&#x6216;&#x8868;</li>
<li>&#x7528;&#x6237;&#x540D;</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-keyword">GRANT</span> <span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">ON</span> crashcourse.* <span class="hljs-keyword">TO</span> bforta;    <span class="hljs-comment">-- &#x5141;&#x8BB8;bforta&#x7528;&#x6237;&#x5728;crashcourse.*&#x4E0A;&#x4F7F;&#x7528;select</span>
</code></pre>
<p>&#x53CD;&#x64CD;&#x4F5C;<code>REVOKE</code>&#x64A4;&#x9500;&#x6743;&#x9650;</p>
<pre><code class="lang-sql"><span class="hljs-keyword">REVOKE</span> <span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">ON</span> crashcourse.* <span class="hljs-keyword">TO</span> bforta;    <span class="hljs-comment">-- &#x64A4;&#x9500;bforta&#x7528;&#x6237;&#x5728;crashcourse.*&#x4E0A;&#x4F7F;&#x7528;select&#x6743;&#x9650;</span>
</code></pre>
<p>&#x51E0;&#x4E2A;&#x5C42;&#x6B21;&#x4E0A;&#x7684;&#x63A7;&#x5236;&#x8BBF;&#x95EE;&#x6743;&#x9650;</p>
<ul>
<li>&#x6574;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#xFF1A;GRANT ALL&#x548C;REVOKE ALL</li>
<li>&#x6574;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#xFF1A;&#x4F7F;&#x7528;ON database.*</li>
<li>&#x7279;&#x5B9A;&#x7684;&#x8868;&#xFF1A;&#x4F7F;&#x7528;ON database.table</li>
<li>&#x7279;&#x5B9A;&#x7684;&#x5217;</li>
<li>&#x7279;&#x5B9A;&#x7684;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;</li>
</ul>
<h5 id="&#x66F4;&#x6539;&#x53E3;&#x4EE4;">&#x66F4;&#x6539;&#x53E3;&#x4EE4;</h5>
<pre><code class="lang-sql"><span class="hljs-keyword">set</span> <span class="hljs-keyword">password</span> <span class="hljs-keyword">for</span> bforta = <span class="hljs-keyword">Password</span>(<span class="hljs-string">&apos;n3w p@$$w0rd&apos;</span>);
</code></pre>
<p>&#x4E0D;&#x6307;&#x5B9A;&#x7528;&#x6237;&#x540D;&#x5219;&#x66F4;&#x65B0;&#x5F53;&#x524D;&#x767B;&#x5F55;&#x7528;&#x6237;&#x7684;&#x53E3;&#x4EE4;</p>
<h3 id="&#x6570;&#x636E;&#x5E93;&#x7EF4;&#x62A4;">&#x6570;&#x636E;&#x5E93;&#x7EF4;&#x62A4;</h3>
<h4 id="&#x5907;&#x4EFD;&#x6570;&#x636E;">&#x5907;&#x4EFD;&#x6570;&#x636E;</h4>
<h4 id="&#x8FDB;&#x884C;&#x6570;&#x636E;&#x5E93;&#x7EF4;&#x62A4;">&#x8FDB;&#x884C;&#x6570;&#x636E;&#x5E93;&#x7EF4;&#x62A4;</h4>
<h4 id="&#x8BCA;&#x65AD;&#x542F;&#x52A8;&#x95EE;&#x9898;">&#x8BCA;&#x65AD;&#x542F;&#x52A8;&#x95EE;&#x9898;</h4>
<h4 id="&#x67E5;&#x770B;&#x65E5;&#x5FD7;&#x6587;&#x4EF6;">&#x67E5;&#x770B;&#x65E5;&#x5FD7;&#x6587;&#x4EF6;</h4>
<h3 id="&#x6539;&#x5584;&#x6027;&#x80FD;">&#x6539;&#x5584;&#x6027;&#x80FD;</h3>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="MVCC.html" class="navigation navigation-prev " aria-label="Previous page: MVCC">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Redis.html" class="navigation navigation-next " aria-label="Next page: Redis">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"MySQL","level":"1.11.2","depth":2,"next":{"title":"Redis","level":"1.11.3","depth":2,"path":"数据库/Redis.md","ref":"数据库/Redis.md","articles":[]},"previous":{"title":"MVCC","level":"1.11.1","depth":2,"path":"数据库/MVCC.md","ref":"数据库/MVCC.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","-lunr","-sharing","-anchor-navigation-ex","todo","code","-katex","github","-summary","search-pro","chapter-fold","theme-comscore","toggle-chapters","flexible-alerts"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"github":{"url":"https://github.com/BluePrintYang"},"todo":{},"search-pro":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"},"theme-comscore":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"Attention"},"note":{"className":"info","icon":"fa fa-info-circle","label":"Note"},"style":"callout","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"Tip"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"Warning"}},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"yanglonglong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"My Study Note","language":"zh-hans","links":{"sidebar":{"My Blog":"https://www.yangllong.top/"}},"gitbook":"*"},"file":{"path":"数据库/MySQL.md","mtime":"2020-06-29T16:04:36.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-14T07:15:50.272Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

